예제 #1
0
bool SDCardFile::open(bool create) {
  if (!exists) {
    if (create) {
      SDCardEntry parentDir(dir);
      if (!parentDir.exists)
	return false;
      
      fat_dir_struct *dd = fat_open_dir(SDCard.fs, &parentDir.dir_entry);
      if (!fat_create_file(dd, name, &dir_entry)
	  && strcmp(name, dir_entry.long_name)) {
	fat_close_dir(dd);
	return false;
      }
      fat_close_dir(dd);
    } else {
      return false;
    }
  }
  
  fd = fat_open_file(SDCard.fs, &dir_entry);
  if (fd != NULL)
    return true;
  else
    return false;
}
예제 #2
0
struct fat_file_struct* open_file_in_dir(struct fat_fs_struct* fs, struct fat_dir_struct* dd, const char* name)
{
    struct fat_dir_entry_struct file_entry;
    if(!find_file_in_dir(fs, dd, name, &file_entry))
        return 0;

    return fat_open_file(fs, &file_entry);
}
예제 #3
0
struct fat_file_struct* FatFsClass::open(const char *file_name)
{
	struct fat_dir_entry_struct directory;
	if(find_file_in_dir(file_name, &directory)){
		return fat_open_file(_fs, &directory);
	}
	return 0;
}
예제 #4
0
파일: SDCard.cpp 프로젝트: CyrilLD/sjfw
bool openFile(const char* name, struct fat_file_struct** file)
{
  struct fat_dir_entry_struct fileEntry;
  if(!findFileInDir(name, &fileEntry))
  {
    return false;
  }

  *file = fat_open_file(fs, &fileEntry);
  return true;
}
예제 #5
0
uint8_t open_file_in_dir(struct fat_fs_struct* fs, struct fat_dir_struct* dd, const char* name,
					 File *file)
{
  struct fat_dir_entry_struct file_entry;

  if(!find_file_in_dir(fs, dd, name, &file_entry))
  {
    //Serial.println("File not found");
    return 0;
  }

  *file = fat_open_file(fs, &file_entry);
  return 1;
}
예제 #6
0
파일: main.c 프로젝트: antoniovillena/zxuno
void load_rom(file_descr_t *entry)
{
	file_t file;
	int i;
	DWORD size;

	console_clear();
	console_puts("Loading ");
	for (i=0; i<8; i++) {
		console_putc(entry->name[i]);
	}
	console_putc('.');
	for (i=8; i<11; i++) {
		console_putc(entry->name[i]);
	}
	console_puts("\n\n");

	fat_open_file(&file, entry->cluster);
	size = 0;
	while (1) {
		UBYTE* data;
		if ((size&0x3fff)==0) {
			// switch page 1
			*((UBYTE*)0xffff) = (size>>14)&0xff;
		}
		// write to page 2
		data = 0x8000+(size&0x3fff);
		data = fat_load_file_sector(&file,data);
		if (data==0) {
			console_puts("Error while reading file\n");
		} else if (data==FAT_EOF) {
			console_gotoxy(0,2);
			return;
		} else {
			// process data
			size += 0x200;
			if ((size)%16384 == 0)
			   console_puts(".");
			//console_gotoxy(0,3);
			//console_print_dword(size);
			//console_puts(" bytes loaded");
		}
	}
예제 #7
0
int syscall_file_open(char *filename, int mode)
{
  return fat_open_file(filename, mode);
}