25 |
#include <config.h> |
#include <config.h> |
26 |
#endif |
#endif |
27 |
|
|
28 |
#ifdef _WIN32_ |
#ifdef WIN32 |
29 |
# define _WIN32_WINNT 0x0500 |
# define _WIN32_WINNT 0x0500 |
30 |
# include <windows.h> |
# include <windows.h> |
31 |
# include <conio.h> |
# include <conio.h> |
32 |
#else |
#else |
|
# include <sys/types.h> |
|
|
# include <sys/stat.h> |
|
|
# include <dirent.h> |
|
33 |
# include <errno.h> |
# include <errno.h> |
34 |
# include <dlfcn.h> |
# include <dlfcn.h> |
35 |
#endif |
#endif |
36 |
|
|
37 |
|
#include <unistd.h> |
38 |
|
#include <dirent.h> |
39 |
|
#include <sys/stat.h> |
40 |
|
#include <sys/types.h> |
41 |
|
|
42 |
// for testing the disk streaming methods |
// for testing the disk streaming methods |
43 |
#define USE_DISK_STREAMING 1 |
#define USE_DISK_STREAMING 1 |
44 |
|
|
97 |
|
|
98 |
void PrintLastError(char* file, int line) |
void PrintLastError(char* file, int line) |
99 |
{ |
{ |
100 |
#ifdef _WIN32_ |
#ifdef WIN32 |
101 |
LPVOID lpMsgBuf; |
LPVOID lpMsgBuf; |
102 |
FormatMessage( |
FormatMessage( |
103 |
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
123 |
#define SHOWERROR PrintLastError(__FILE__,__LINE__) |
#define SHOWERROR PrintLastError(__FILE__,__LINE__) |
124 |
|
|
125 |
static void printUsage() { |
static void printUsage() { |
126 |
#ifdef _WIN32_ |
#ifdef WIN32 |
127 |
printf( |
printf( |
128 |
"akaiextract <source-drive-letter>: <destination-dir>\n" |
"akaiextract <source-drive-letter>: <destination-dir>\n" |
129 |
"by Sebastien Métrot (meeloo@meeloo.net)\n\n" |
"by Sebastien Métrot (meeloo@meeloo.net)\n\n" |
190 |
|
|
191 |
// open input source |
// open input source |
192 |
DiskImage* pImage = NULL; |
DiskImage* pImage = NULL; |
193 |
#ifdef _WIN32_ |
#ifdef WIN32 |
194 |
char drive = toupper(*(argv[1]))-'A'; |
char drive = toupper(*(argv[1]))-'A'; |
195 |
printf("opening drive %c:\n",drive+'a'); |
printf("opening drive %c:\n",drive+'a'); |
196 |
pImage = new DiskImage(drive); |
pImage = new DiskImage(drive); |
306 |
if (!dir) { |
if (!dir) { |
307 |
if (errno == ENOENT) { |
if (errno == ENOENT) { |
308 |
struct stat filestat; |
struct stat filestat; |
309 |
|
#ifdef WIN32 |
310 |
|
if (stat(outPath, &filestat) < 0) { |
311 |
|
#else |
312 |
if (lstat(outPath, &filestat) < 0) { |
if (lstat(outPath, &filestat) < 0) { |
313 |
|
#endif |
314 |
printf("Creating output directory '%s'...", outPath); |
printf("Creating output directory '%s'...", outPath); |
315 |
fflush(stdout); |
fflush(stdout); |
316 |
|
#ifdef WIN32 |
317 |
|
if (mkdir(outPath) < 0) { |
318 |
|
#else |
319 |
if (mkdir(outPath, 0770) < 0) { |
if (mkdir(outPath, 0770) < 0) { |
320 |
|
#endif |
321 |
perror("failed"); |
perror("failed"); |
322 |
errorOccured = true; |
errorOccured = true; |
323 |
} |
} |
324 |
else printf("ok\n"); |
else printf("ok\n"); |
325 |
} |
} |
326 |
else { |
else { |
327 |
|
#if !defined(WIN32) |
328 |
if (!S_ISLNK(filestat.st_mode)) { |
if (!S_ISLNK(filestat.st_mode)) { |
329 |
|
#endif |
330 |
printf("Cannot create output directory '%s': ", outPath); |
printf("Cannot create output directory '%s': ", outPath); |
331 |
printf("a file of that name already exists\n"); |
printf("a file of that name already exists\n"); |
332 |
errorOccured = true; |
errorOccured = true; |
333 |
|
#if !defined(WIN32) |
334 |
} |
} |
335 |
|
#endif |
336 |
} |
} |
337 |
} |
} |
338 |
else { |
else { |
450 |
|
|
451 |
delete pAkai; |
delete pAkai; |
452 |
delete pImage; |
delete pImage; |
453 |
#if _WIN32_ |
#if WIN32 |
454 |
while(!_kbhit()); |
while(!_kbhit()); |
455 |
#endif |
#endif |
456 |
} |
} |