/[svn]/libgig/trunk/src/tools/akaiextract.cpp
ViewVC logotype

Diff of /libgig/trunk/src/tools/akaiextract.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2573 by schoenebeck, Thu May 22 12:14:04 2014 UTC revision 2574 by schoenebeck, Thu May 22 15:54:02 2014 UTC
# Line 25  Line 25 
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    
# Line 95  template<class T> inline std::string ToS Line 97  template<class T> inline std::string ToS
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 |
# Line 121  void PrintLastError(char* file, int line Line 123  void PrintLastError(char* file, int line
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"
# Line 188  int main(int argc, char** argv) { Line 190  int main(int argc, char** argv) {
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);
# Line 304  int main(int argc, char** argv) { Line 306  int main(int argc, char** argv) {
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 {
# Line 436  int main(int argc, char** argv) { Line 450  int main(int argc, char** argv) {
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  }  }

Legend:
Removed from v.2573  
changed lines
  Added in v.2574

  ViewVC Help
Powered by ViewVC