Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <dirent.h>
- #include <string.h>
- #include <time.h>
- //#include <curses.h>
- int main(void)
- {
- pid_t child;
- DIR* d;
- struct dirent* de;
- int i, c, k, number;
- char s[256], cmd[256], dirNames[256][256], regNames[256][256];
- time_t t;
- while(1)
- {
- t = time( NULL );
- printf( "\nTime: %s\n", ctime( &t ));
- getcwd(s, 200);
- printf( "Current Directory: %s\n", s );
- d = opendir( "." );
- c = 0;
- while( (de = readdir(d)) )
- {
- if( ((de->d_type) & DT_DIR) )
- {
- strcpy(dirNames[c], (de->d_name));
- printf("%d Directory: %s\n", c, de->d_name);
- c++;
- }
- }
- closedir(d);
- d = opendir( "." );
- c = 0;
- while( (de = readdir(d)) )
- {
- if( ((de->d_type) & DT_REG) )
- {
- strcpy(regNames[c], (de->d_name));
- c++;
- }
- }
- int n = 0;
- while( n < c )
- {
- printf( "Files %d: %s\n", n, regNames[n] );
- if( n%9 == 0 && n!= 0 )
- {
- printf( "Hit N for Next\nHit P for Previous\nHit Q to choose\n" );
- k = getchar();
- if( k == 'N' || k == 'n' )
- {
- n++;
- continue;
- }
- else if ( k == 'P' || k == 'p' )
- {
- if( n >= 9 )
- {
- n = n - 9;
- continue;
- }
- else
- printf("Can't go previous\n");
- }
- else
- {
- break;
- }
- }
- n++;
- }
- closedir(d);
- printf("---------------------------------------------------------\n\n");
- printf("Press:\ne for Edit\nr for Run\nc for Change directory\nq for Quit\n");
- c = getchar(); getchar();
- switch( c )
- {
- case 'q': exit(0);
- case 'e': printf( "Edit what? (input number): " );
- scanf("%d", &number);
- strcpy(regNames[n], s);
- strcpy(cmd, "pico ");
- strcat(cmd, s);
- system(cmd);
- break;
- case 'r': printf ( "Run what?: ");
- scanf("%s", cmd);
- system(cmd);
- break;
- case 'c': printf( "Change to? ");
- scanf("%s", cmd);
- chdir(cmd);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement