Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. ImportFileHandle *FLACImportPlugin::Open(wxString filename)
  2. {
  3.    // First check if it really is a FLAC file
  4.  
  5.    int cnt;
  6.    wxFile binaryFile;
  7.    if (!binaryFile.Open(filename)) {
  8.       return false; // File not found
  9.    }
  10.  
  11. #ifdef USE_LIBID3TAG
  12.    // Skip any ID3 tags that might be present
  13.    id3_byte_t query[ID3_TAG_QUERYSIZE];
  14.    cnt = binaryFile.Read(query, sizeof(query));
  15.    cnt = id3_tag_query(query, cnt);
  16.    binaryFile.Seek(cnt);
  17. #endif
  18.  
  19.    char buf[5];
  20.    cnt = binaryFile.Read(buf, 4);
  21.    binaryFile.Close();
  22.  
  23.    if (cnt == wxInvalidOffset || strncmp(buf, FLAC_HEADER, 4) != 0) {
  24.       // File is not a FLAC file
  25.       return false;
  26.    }
  27.  
  28.    // Open the file for import
  29.    FLACImportFileHandle *handle = new FLACImportFileHandle(filename);
  30.  
  31.    bool success = handle->Init();
  32.    if (!success) {
  33.       delete handle;
  34.       return NULL;
  35.    }
  36.  
  37.    return handle;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement