2 * Hyper Operating System Application Framework
4 * @file filedump_main.c
5 * @brief %jp{ファイルダンプコマンド}
7 * Copyright (C) 2006-2007 by Project HOS
8 * http://sourceforge.jp/projects/hos/
17 #define FILEDUMP_BUFSIZE 4096
20 int FileDump_Main(int argc, char *argv[])
23 unsigned char *pubBuf;
24 unsigned long ulSize = 0x7fffffff;
25 unsigned long ulPos = 0;
34 " %s filename [size] [offest]\n\n",
43 ulSize = (int)strtoul(argv[2], 0, 0);
47 ulPos = (int)strtoul(argv[3], 0, 0);
52 if ( (hFile = File_Open(argv[1], FILE_OPEN_READ)) == HANDLE_NULL )
56 ulPos = (unsigned long)File_Seek(hFile, ulPos, FILE_SEEK_SET);
59 pubBuf = (unsigned char *)Memory_Alloc(FILEDUMP_BUFSIZE);
69 if ( ulSize > FILEDUMP_BUFSIZE )
71 iReadSize = FILEDUMP_BUFSIZE;
75 iReadSize = (int)ulSize;
78 iReadSize = File_Read(hFile, pubBuf, iReadSize);
85 for ( i = 0; i < iReadSize; i++ )
89 StdIo_PrintFormat("%08lx: ", ulPos);
91 StdIo_PrintFormat("%02x ", pubBuf[i]);
95 StdIo_PrintFormat("\n");
99 StdIo_PrintFormat("\n");