Logo Search packages:      
Sourcecode: qlix version File versions  Download package

void MtpDevice::createFileStructure (  )  [private]

Get the file list and iterate over and add them to their parent folder This function must be called after createFolderStructure

Definition at line 505 of file MtpDevice.cpp.

References MTP::Folder::AddChildFile(), MTP::Folder::FileCount(), find(), MTP::File::Name(), MTP::File::ParentID(), MTP::File::SetParentFolder(), and MTP::File::SetRowIndex().

Referenced by createObjectStructure().

{
  LIBMTP_file_t* fileRoot = LIBMTP_Get_Filelisting_With_Callback(_device, NULL, NULL);
  while (fileRoot)
  {
    MTP::File* currentFile = new MTP::File(fileRoot);
    cout << "Created file: " << currentFile << endl;
    //Sanity check: find previous instances for crosslinks
    MTP::File* prev_file = (MTP::File*) find(currentFile->ID(), MtpFile); 
    //crosslink check
    if(prev_file)
    {
      cerr << "File crosslinked with another file please file a bug report at: "
           << "caffein@gmail.com" << endl;
      cerr << " Previous file's name: " << prev_file->Name() << endl;
      cerr << " New file's name: " << currentFile->Name() << endl;
      assert(false);
    }
    _fileMap[currentFile->ID()] = currentFile; 

    MTP::Folder* const parentFolder=
                       (MTP::Folder*) find(currentFile->ParentID(), MtpFolder);
    if(! parentFolder)
    {
      cerr << "Database corruption. Parent folder for file:" << currentFile->ID()
           << " which has ID: " << currentFile->ParentID() 
           << " was not discovered" << endl;
      assert(false);
    }
    currentFile->SetRowIndex(parentFolder->FileCount());
    parentFolder->AddChildFile(currentFile);
    if (parentFolder->ID() == 0)
      cout << "Added new child folder to root, now file count: " << parentFolder->FileCount() << endl;
    currentFile->SetParentFolder(parentFolder);

    //move on to the next file
    fileRoot = fileRoot->next;
  }
}


Generated by  Doxygen 1.6.0   Back to index