Пример #1
0
static inline int file_rewrite(char *path,dword pos1,dword pos2,void *ukaz,dword size)
{
	FS_struct70 file_read_struct;
	file_read_struct.p00 = 3;
	file_read_struct.p04 = pos1;
	file_read_struct.p08 = pos2;
	file_read_struct.p12 = size;
	file_read_struct.p16 = ukaz;
	file_read_struct.p20 = 0;
	file_read_struct.p21 = path;
	char c = FS_file_70(&file_read_struct);
	if(c)
	{
		sprintf(&BUF_COPY,"'Error rewrite file (%s) file: %s.'E",string_error_code(c),path);
		file_run("/sys/@notify",&BUF_COPY);
	}
	return c;
}
Пример #2
0
static inline int file_read_binary(char *path,unsigned pos,unsigned size,void *adr)
{
	FS_struct70 file_read_struct;
	file_read_struct.p00 = 0;
	file_read_struct.p04 = pos;
	file_read_struct.p08 = 0;
	file_read_struct.p12 = size;
	file_read_struct.p16 = (unsigned)adr;
	file_read_struct.p20 = 0;
	file_read_struct.p21 = path;
	char c = FS_file_70(&file_read_struct);
	if(c)
	{
		sprintf(&BUF_COPY,"'Error read file (%s) file: %s.'E",string_error_code(c),path);
		file_run("/sys/@notify",&BUF_COPY);
	}
	return c;
}
Пример #3
0
static inline int file_mkdir(char *path)
{
	FS_struct70 file_read_struct;
	file_read_struct.p00 = 9;
	file_read_struct.p04 = 0;
	file_read_struct.p08 = 0;
	file_read_struct.p12 = 0;
	file_read_struct.p16 = 0;
	file_read_struct.p20 = 0;
	file_read_struct.p21 = path;
	char c = FS_file_70(&file_read_struct);
	if(c)
	{
		sprintf(&BUF_COPY,"'Error make dir: %s. Info: %s.'E",string_error_code(c),path);
		file_run("/sys/@notify",&BUF_COPY);
	}
	return c;
}
Пример #4
0
int start_run()
{
    FILE* work_file;

    char *start_menu[] = {
        "Create file;\n",
        "Open file;\n",
        "Read file;\n",
        "Delete file;\n",
        "Exit program;\n",
    };

    char menu_symb[] = "0";
    char random = '\0';
    char path[PATH_LEN + 1];
    char full_path[FPATH_LEN + 1];

    int fill_number = 0;
    int menu_count = 0;
    int incorrect_choice = 1;
    int exit = 0;

    do
    {
        incorrect_choice = 1;

        system("clear");
        for(menu_count = 0; menu_count < 5; menu_count++)
            printf("%d) %s", menu_count + 1, start_menu[menu_count]);

        printf("Input the number of menu item:\n");
        while(incorrect_choice)
        {
            menu_symb[0] = getche();
            if(!strpbrk(menu_symb, "12345"))
                printf("Unknown value: %c; repeat the choice\n", menu_symb[0]);
            else
                incorrect_choice = 0;
        }

        switch(menu_symb[0])
        {
        case '1':
        {
            puts("Input the name of the file to create:");
            puts("(If you wish inner directories, "
                 "type them with '/' separator;");
            puts("Further this path may be appended "
                 "to executable's base dir)");
            string_input(stdin, PATH_LEN, path, 0);
            getcwd(full_path, FPATH_LEN + 1);
            strcat(full_path, "/");
            strcat(full_path, path);

            work_file = file_create(full_path);
            if(work_file)
            {
                incorrect_choice = 1;

                puts("Do you want to fill the file with random values?[Y/N]");
                while(incorrect_choice)
                {
                    random = getche();
                    if(!strpbrk(&random, "ynYN"))
                        printf("Unknown value: %c; repeat the choice\n",
                               random);
                    else
                        incorrect_choice = 0;
                }
                if(random == 'y' || random == 'Y')
                {
                    puts("Input the number of items to create:");
                    fill_number = integer_input(1, 200);
                    random_fill(work_file, fill_number);
                }

                file_run(work_file);
            }
        }
            break;
        case '2':
        {
            puts("Input the name of the file to open & operate with:");
            string_input(stdin, PATH_LEN, path, 0);
            getcwd(full_path, FPATH_LEN + 1);
            strcat(full_path, "/");
            strcat(full_path, path);

            if(!file_exist(full_path))
                alert("\tNo such file or directory;");
            else
            {
                work_file = file_open(full_path);
                if(work_file)
                    file_run(work_file);
            }
        }
            break;
        case '3':
        {
            puts("Input the name of the file to read:");
            string_input(stdin, PATH_LEN, path, 0);
            getcwd(full_path, FPATH_LEN + 1);
            strcat(full_path, "/");
            strcat(full_path, path);

            if(!file_exist(full_path))
                alert("\tNo such file or directory;");
            else
            {
                work_file = file_open(full_path);
                if(work_file)
                    file_read(work_file);
            }
        }
            break;
        case '4':
        {
            puts("Input the name of the file to delete:");
            string_input(stdin, PATH_LEN, path, 0);
            getcwd(full_path, FPATH_LEN + 1);
            strcat(full_path, "/");
            strcat(full_path, path);

            if(!file_exist(full_path))
                alert("\tNo such file or directory;");
            else
                if(remove(full_path))
                    alert("\tUnable to delete this file;");
        }
            break;
        case '5':
        {
            printf("Good luck;\n");
            exit = 1;
        }
            break;
        }
    }while(!exit);

    return menu_symb[0] - '0';
}