Ejemplo n.º 1
0
void mpxcmd_ls( int argc, char *argv[] )
{
	int	retval;
	char	*dir;
	int 	num_files;
	char	file_name[MAX_FILENAME_LEN+1];
	long	file_size;

	if ( argc == 1 ){
		dir = MPX_DEFAULT_EXE_DIR;
	}
	else if ( argc == 2 ){
		dir = argv[1];
	}
	else {
		printf("ERROR: Wrong number of arguments to 'ls'.\n");
		printf("       Type 'help ls' for usage information.\n");
		return;
	}

	retval = sys_open_dir( dir );
	if ( retval != 0 ){
		printf("ERROR: sys_open_dir() failed");
		printf("trying to open directory '%s'.\n", dir);
		return;
	}

	printf("\n");
	printf("    Listing of files in directory '%s':\n", dir);
	printf("\n");
	printf("File Name:         File Size (in bytes):\n");
	printf("---------------    ------------------------------\n");

	num_files = 0;
	for(;;){
		retval = sys_get_entry(file_name, MAX_FILENAME_LEN, &file_size);
		if ( retval == 0 ) {
			printf("%-15s    %30ld\n", file_name, file_size);
			num_files++;
		}
		else if ( retval == ERR_SUP_NOENTR ) {
			break;
		}
		else {
			printf("ERROR: sys_get_entry() failed");
			printf("trying to read directory '%s'.\n", dir);
			printf("Giving up on this directory.\n");
			return;
		}
	}

	printf("\n");
	printf("Total files in directory: %d\n", num_files);

	retval = sys_close_dir();
	if ( retval != 0 ){
		printf("ERROR: sys_close_dir() returned an error.\n");
	}
}
Ejemplo n.º 2
0
/**
	Procedure: handler_display_mpx

	Purpose: Displays Directory of Available MPX Process Files

	Parameters: None  

	Return value: None

	Calls: sizeOfPointer, sys_open_dir, sys_close_dir, sys_get_entry

	Globals: error

	Errors: Invalid Directory, Directory Not Open, No More Directory Entries, Read Failed, Name To Long For Buffer, No Directory Is Open.
**/
void handler_display_mpx(){
	char *Buffer= NULL;
	char BufferArray[80] = {0};
	char currentFile[40];
	long j = 0;
	int error, i = 0;
	int nameSize = 40;
	printf("\nWelcome to mpx");
	printf("\nPlease enter the directory to be opened it cannot contain spaces\n");
	Buffer = keyboardInput(0);
	
	while(i<sizeOfPointer(Buffer)){
		//printf("%c",Buffer[i]);
		BufferArray[i] = Buffer[i];
		i++;
	}
	if(sizeOfPointer(Buffer)==0){
		//printf("success");
		getcwd(BufferArray,80);
	}
	error = sys_open_dir(BufferArray);
	errorCheck(error);
	//printf("%s",BufferArray);
	if(error ==0){
		i = 0;
		printConstant =0;
		while(error == 0){
			error = sys_get_entry(currentFile,nameSize,&j);
			if(error == 0){
				i++;
				printf("\nFilename:%s       \tBuffersize:%d\tFile Size:%ld",currentFile,nameSize,j);
				printInterrupt();
			}
			//printf("\n%d",error);
		}
		if(error != -113){
			errorCheck(error);
		}
		else{
			error = sys_close_dir();
			errorCheck(error);
			//printf("\n%d",error);
			if(i == 0){
				if(Buffer[0] == 10){
					printf("The current directory contains no mpx files\n");
				}
				else{
					printf("No mpx files are in that directory\n");
				}
			}
			
		}
	}
	printf("\n");
}
Ejemplo n.º 3
0
void scan_directory(database* db, const wchar* dir_name)
{
    sys_dir_file* dir = sys_first_file(dir_name);

    if(dir)
    {
        do
        {
            if(sys_is_directory(dir))
                db_add_local_dir(db, sys_file_name(dir));
            else if(scan_check_file_extension(sys_file_name(dir)))
                db_add_local_file(db, sys_file_name(dir), sys_mod_time(dir));
        }
        while(sys_next_file(dir));
    }
    sys_close_dir(dir);
}