8 #include <disktool_common.h>
11 int main(int argc, char *argv[])
14 for( int i = 1; i < argc; i ++ )
16 if( strcmp("--image", argv[i]) == 0 || strcmp("-i", argv[i]) == 0 ) {
19 fprintf(stderr, "--image/-i takes 2 arguments (ident and path)\n");
23 if( DiskTool_MountImage(argv[i+1], argv[i+2]) ) {
24 fprintf(stderr, "Unable to mount '%s' as '%s'\n", argv[i+2], argv[i+1]);
32 if( strcmp("ls", argv[i]) == 0 ) {
34 fprintf(stderr, "ls 1 argument (path)\n");
38 DiskTool_ListDirectory(argv[i+1]);
43 if( strcmp("cp", argv[i]) == 0 ) {
46 fprintf(stderr, "cp takes 2 arguments (source and destination)\n");
50 DiskTool_Copy(argv[i+1], argv[i+2]);
59 // NOTE: This is in a native compiled file because it needs access to the real errno macro
60 int *Threads_GetErrno(void)
65 // TODO: Move into a helper lib?
66 void itoa(char *buf, uint64_t num, int base, int minLength, char pad)
68 char fmt[] = "%0ll*x";
71 case 8: fmt[5] = 'o'; break;
72 case 10: fmt[5] = 'd'; break;
73 case 16: fmt[5] = 'x'; break;
77 sprintf(buf, fmt+1, minLength, num);
80 sprintf(buf, fmt, minLength, num);
84 int strpos(const char *Str, char Ch)
86 const char *r = strchr(Str, Ch);
91 int strucmp(const char *s1, const char *s2)
93 return strcasecmp(s1, s2);
96 uint64_t DivMod64U(uint64_t value, uint64_t divisor, uint64_t *remainder)
99 *remainder = value % divisor;
100 return value / divisor;