/[svn]/libgig/trunk/src/gigextract.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gigextract.cpp

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

revision 902 by persson, Sat Jul 22 14:22:01 2006 UTC revision 1869 by persson, Sun Mar 22 11:13:25 2009 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file loader library    *   *   libgig - C++ cross-platform Gigasampler format file access library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003-2005 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2007 by Christian Schoenebeck                      *
6   *                              <cuse@users.sourceforge.net>               *   *                              <cuse@users.sourceforge.net>               *
7   *                                                                         *   *                                                                         *
8     *   This program is part of libgig.                                       *
9     *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 2 of the License, or     *
# Line 44  Line 46 
46  #include <stdlib.h>  #include <stdlib.h>
47  #include <sys/types.h>  #include <sys/types.h>
48  #include <sys/stat.h>  #include <sys/stat.h>
 #include <dirent.h>  
49  #include <errno.h>  #include <errno.h>
50  #include <dlfcn.h>  
51    #include "gig.h"
52    
53    #ifdef _MSC_VER
54    #define S_ISDIR(x) (S_IFDIR & (x))
55    #define S_IWUSR S_IWRITE
56    #define S_IXUSR S_IEXEC
57    #endif
58    
59    #if POSIX
60    # include <dlfcn.h>
61    #endif
62    
63  // only libsndfile is available for Windows, so we use that for writing the sound files  // only libsndfile is available for Windows, so we use that for writing the sound files
64  #ifdef WIN32  #ifdef WIN32
# Line 66  Line 78 
78  # include <audiofile.h>  # include <audiofile.h>
79  #endif // HAVE_SNDFILE  #endif // HAVE_SNDFILE
80    
 #include "gig.h"  
   
81  using namespace std;  using namespace std;
82    
83  typedef map<unsigned int, bool> OrderMap;  typedef map<unsigned int, bool> OrderMap;
# Line 123  int main(int argc, char *argv[]) { Line 133  int main(int argc, char *argv[]) {
133          return EXIT_FAILURE;          return EXIT_FAILURE;
134      }      }
135      fclose(hFile);      fclose(hFile);
136      DIR* dir = opendir(argv[2]);      struct stat buf;
137      if (!dir) {      if (stat(argv[2], &buf) == -1) {
138          cout << "Unable to open DESTDIR: ";          cout << "Unable to open DESTDIR: ";
139          switch (errno) {          switch (errno) {
140              case EACCES:  cout << "Permission denied." << endl;              case EACCES:  cout << "Permission denied." << endl;
141                            break;                            break;
             case EMFILE:  cout << "Too many file descriptors in use by process." << endl;  
                           break;  
             case ENFILE:  cout << "Too many files are currently open in the system." << endl;  
                           break;  
142              case ENOENT:  cout << "Directory does not exist, or name is an empty string." << endl;              case ENOENT:  cout << "Directory does not exist, or name is an empty string." << endl;
143                            break;                            break;
144              case ENOMEM:  cout << "Insufficient memory to complete the operation." << endl;              case ENOMEM:  cout << "Insufficient memory to complete the operation." << endl;
# Line 142  int main(int argc, char *argv[]) { Line 148  int main(int argc, char *argv[]) {
148              default:      cout << "Unknown error" << endl;              default:      cout << "Unknown error" << endl;
149          }          }
150          return EXIT_FAILURE;          return EXIT_FAILURE;
151        } else if (!S_ISDIR(buf.st_mode)) {
152            cout << "Unable to open DESTDIR: Is not a directory." << endl;
153            return EXIT_FAILURE;
154        } else if (!(S_IWUSR & buf.st_mode) || !(S_IXUSR & buf.st_mode)) {
155            cout << "Unable to open DESTDIR: Permission denied." << endl;
156            return EXIT_FAILURE;
157      }      }
     if (dir) closedir(dir);  
158      try {      try {
159          RIFF::File* riff = new RIFF::File(argv[1]);          RIFF::File* riff = new RIFF::File(argv[1]);
160          gig::File*  gig  = new gig::File(riff);          gig::File*  gig  = new gig::File(riff);
# Line 177  void ExtractSamples(gig::File* gig, char Line 188  void ExtractSamples(gig::File* gig, char
188      int samples     = 0;      int samples     = 0;
189      gig::buffer_t decompressionBuffer;      gig::buffer_t decompressionBuffer;
190      decompressionBuffer.Size = 0;      decompressionBuffer.Size = 0;
     unsigned long decompressionBufferSize = 0;  
191      cout << "Seeking for available samples..." << flush;      cout << "Seeking for available samples..." << flush;
192      gig::Sample* pSample = gig->GetFirstSample();      gig::Sample* pSample = gig->GetFirstSample();
193      cout << "OK" << endl << flush;      cout << "OK" << endl << flush;
# Line 379  void closeAFlib() { Line 389  void closeAFlib() {
389  #endif // !HAVE_SNDFILE  #endif // !HAVE_SNDFILE
390    
391  string Revision() {  string Revision() {
392      string s = "$Revision: 1.8 $";      string s = "$Revision: 1.11 $";
393      return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword      return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
394  }  }
395    

Legend:
Removed from v.902  
changed lines
  Added in v.1869

  ViewVC Help
Powered by ViewVC