Advertisement
Guest User

new

a guest
Sep 15th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/types.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <dirent.h>
  5. #include <string.h>
  6. #include <time.h>
  7. //#include <curses.h>
  8.  
  9. int main(void)
  10. {
  11. pid_t child;
  12. DIR* d;
  13. struct dirent* de;
  14. int i, c, k, number;
  15. char s[256], cmd[256], dirNames[256][256], regNames[256][256];
  16. time_t t;
  17.  
  18. while(1)
  19. {
  20. t = time( NULL );
  21. printf( "\nTime: %s\n", ctime( &t ));
  22. getcwd(s, 200);
  23. printf( "Current Directory: %s\n", s );
  24. d = opendir( "." );
  25. c = 0;
  26. while( (de = readdir(d)) )
  27. {
  28. if( ((de->d_type) & DT_DIR) )
  29. {
  30. strcpy(dirNames[c], (de->d_name));
  31. printf("%d Directory: %s\n", c, de->d_name);
  32. c++;
  33. }
  34. }
  35. closedir(d);
  36.  
  37. d = opendir( "." );
  38. c = 0;
  39. while( (de = readdir(d)) )
  40. {
  41. if( ((de->d_type) & DT_REG) )
  42. {
  43. strcpy(regNames[c], (de->d_name));
  44. c++;
  45. }
  46. }
  47. int n = 0;
  48. while( n < c )
  49. {
  50. printf( "Files %d: %s\n", n, regNames[n] );
  51. if( n%9 == 0 && n!= 0 )
  52. {
  53. printf( "Hit N for Next\nHit P for Previous\nHit Q to choose\n" );
  54. k = getchar();
  55. if( k == 'N' || k == 'n' )
  56. {
  57. n++;
  58. continue;
  59. }
  60. else if ( k == 'P' || k == 'p' )
  61. {
  62. if( n >= 9 )
  63. {
  64. n = n - 9;
  65. continue;
  66. }
  67. else
  68. printf("Can't go previous\n");
  69. }
  70. else
  71. {
  72. break;
  73. }
  74. }
  75. n++;
  76. }
  77. closedir(d);
  78. printf("---------------------------------------------------------\n\n");
  79. printf("Press:\ne for Edit\nr for Run\nc for Change directory\nq for Quit\n");
  80. c = getchar(); getchar();
  81. switch( c )
  82. {
  83. case 'q': exit(0);
  84. case 'e': printf( "Edit what? (input number): " );
  85. scanf("%d", &number);
  86. strcpy(regNames[n], s);
  87. strcpy(cmd, "pico ");
  88. strcat(cmd, s);
  89. system(cmd);
  90. break;
  91. case 'r': printf ( "Run what?: ");
  92. scanf("%s", cmd);
  93. system(cmd);
  94. break;
  95. case 'c': printf( "Change to? ");
  96. scanf("%s", cmd);
  97. chdir(cmd);
  98. break;
  99. }
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement