135 int argc = oargc - 1;
136 char**
argv = oargv + 1;
141 fprintf(
stderr,
"Error: First parameter must be a filename.\n");
147 fprintf(
stderr,
"Error: First parameter must be a filename, found '%s' instead.\n",
argv[0]);
169 fprintf(
stderr,
"Error: Expected a command, found '%s' instead.\n", parg);
181 if (
strcmp(parg,
"format") == 0)
217 #define FAT_VOL_LABEL_LEN 11 219 char*
label = vol_label + 2;
232 if ((ch < 0x20) || !
isprint(ch))
257 fprintf(
stderr,
"Error: Header label is limited to 11 printable uppercase ASCII symbols.");
264 fprintf(
stderr,
"Error: Unable to read existing boot sector from image.");
280 fprintf(
stderr,
"Error: Unable to write new boot sector to image.");
286 memcpy(vol_label,
"0:", 2);
296 else if (
strcmp(parg,
"boot") == 0)
308 fprintf(
stderr,
"Error: Unable to open external file '%s' for reading.",
argv[0]);
327 fprintf(
stderr,
"Error: Unable to read existing boot sector from image.");
334 printf(
"TODO: Writing boot sectors for FAT32 images not yet supported.");
340 #define FAT16_HEADER_START 3 341 #define FAT16_HEADER_END 62 348 fprintf(
stderr,
"Error: Unable to write new boot sector to image.");
353 else if (
strcmp(parg,
"add") == 0)
370 fprintf(
stderr,
"Error: Unable to open external file '%s' for reading.",
argv[0]);
385 if (
f_write(&fv,
buff, rdlen, &wrlen) || wrlen < rdlen)
387 fprintf(
stderr,
"Error: Unable to write '%d' bytes to disk.", wrlen);
396 else if (
strcmp(parg,
"extract") == 0)
420 fprintf(
stderr,
"Error: Unable to open external file '%s' for writing.",
argv[1]);
426 while ((
f_read(&fe,
buff,
sizeof(
buff), &rdlen) == 0) && (rdlen > 0))
430 fprintf(
stderr,
"Error: Unable to write '%d' bytes to file.", rdlen);
439 else if (
strcmp(parg,
"move") == 0)
454 else if (
strcmp(parg,
"copy") == 0)
481 while ((
f_read(&fe,
buff,
sizeof(
buff), &rdlen) == 0) && (rdlen > 0))
483 if (
f_write(&fv,
buff, rdlen, &wrlen) || wrlen < rdlen)
485 fprintf(
stderr,
"Error: Unable to write '%d' bytes to disk.", wrlen);
494 else if (
strcmp(parg,
"mkdir") == 0)
508 else if (
strcmp(parg,
"delete") == 0)
517 fprintf(
stderr,
"Error: Unable to delete file or directory.");
522 else if (
strcmp(parg,
"list") == 0)
545 printf(
"Listing directory contents of: %s\n",
root);
547 info.lfname = lfname;
548 info.lfsize =
sizeof(lfname)-1;
#define FAT_VOL_LABEL_LEN
static const WCHAR invalid[]
FRESULT f_mkfs(const TCHAR *path, BYTE sfd, UINT au)
ACPI_SIZE strlen(const char *String)
DSTATUS disk_openimage(BYTE pdrv, const char *imageFileName)
FRESULT f_unlink(const TCHAR *path)
int is_command(const char *parg)
#define PRINT_HELP_AND_QUIT()
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static NTSTATUS disk_write(RDPCLIENT *This, NTHANDLE handle, uint8 *data, uint32 length, uint32 offset, uint32 *result)
FRESULT f_readdir(DIR *dp, FILINFO *fno)
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
#define FAT16_HEADER_START
VOID disk_cleanup(BYTE pdrv)
#define memcpy(s1, s2, n)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
FRESULT f_opendir(DIR *dp, const TCHAR *path)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
FRESULT f_setlabel(const TCHAR *label)
#define NEED_PARAMS(_min_, _max_)
FRESULT f_mkdir(const TCHAR *path)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
int strcmp(const char *String1, const char *String2)
static FATFS g_Filesystem
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
static BOOLEAN disk_read(ULONG DeviceId, u64 physical, void *dest, u32 count)
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
static unsigned char buff[32768]
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)