// Returns a file descriptor for a given file ID. AKRESULT CAkDefaultIOHookDeferred::Open( AkFileID in_fileID, // File ID. AkOpenMode in_eOpenMode, // Open mode. AkFileSystemFlags * in_pFlags, // Special flags. Can pass NULL. bool & io_bSyncOpen, // If true, the file must be opened synchronously. Otherwise it is left at the File Location Resolver's discretion. Return false if Open needs to be deferred. AkFileDesc & out_fileDesc // Returned file descriptor. ) { // We normally consider that calls to ::CreateFile() on a hard drive are fast enough to execute in the // client thread. If you want files to be opened asynchronously when it is possible, this device should // be initialized with the flag in_bAsyncOpen set to true. if ( io_bSyncOpen || !m_bAsyncOpen ) { io_bSyncOpen = true; // Get the full file path, using path concatenation logic. AkOSChar szFullFilePath[AK_MAX_PATH]; if ( GetFullFilePath( in_fileID, in_pFlags, in_eOpenMode, szFullFilePath ) == AK_Success ) { // Open the file with FILE_FLAG_OVERLAPPED and FILE_FLAG_NO_BUFFERING flags. AKRESULT eResult = CAkFileHelpers::OpenFile( szFullFilePath, in_eOpenMode, true, true, out_fileDesc.hFile ); if ( eResult == AK_Success ) { #ifdef AK_USE_METRO_API FILE_STANDARD_INFO info; ::GetFileInformationByHandleEx( out_fileDesc.hFile, FileStandardInfo, &info, sizeof(info) ); out_fileDesc.iFileSize = info.EndOfFile.QuadPart; #else ULARGE_INTEGER Temp; Temp.LowPart = ::GetFileSize( out_fileDesc.hFile,(LPDWORD)&Temp.HighPart ); out_fileDesc.iFileSize = Temp.QuadPart; #endif out_fileDesc.uSector = 0; out_fileDesc.deviceID = m_deviceID; out_fileDesc.pCustomParam = NULL; out_fileDesc.uCustomParamSize = 0; } return eResult; } return AK_Fail; } else { // The client allows us to perform asynchronous opening. // We only need to specify the deviceID, and leave the boolean to false. out_fileDesc.iFileSize = 0; out_fileDesc.uSector = 0; out_fileDesc.deviceID = m_deviceID; out_fileDesc.pCustomParam = NULL; out_fileDesc.uCustomParamSize = 0; return AK_Success; } }
void CSettingDlg::OnBnClickedButtonSetSel2() { std::string dir = GetFullFilePath( GetWindowStlText( GetDlgItem( IDC_EDIT_SET_DB_DIR ) ) ); dir = DirectorySelectDlg( *this, STR_SELECT_BB_DIR, dir.c_str() ); if( dir.size() ) { SetDlgItemText( IDC_EDIT_SET_DB_DIR, dir.c_str() ); } }
void DataCvt_Discrete::WriteExcuteLog() { string path_log = "log_DataCvt_Descrete.txt"; path_log = GetFullFilePath(path_log.c_str()); fstream pSaveFile; pSaveFile.open(path_log.c_str(),ios::out|ios::app); pSaveFile<<"=======================ProcessNum:"<<m_Numproc<<"======================="<<endl; pSaveFile<<"[DEBUG] [TIMESPAN] [IO] "<<Mpi_Finish_Moment-Mpi_Start_Moment-Mpi_Caculate_Time<<"\n"; pSaveFile<<"[DEBUG] [TIMESPAN] [COMPUTING] "<<Mpi_Caculate_Time<<"\n"; pSaveFile<<"[DEBUG] [TIMESPAN] [TOTAL] "<<Mpi_Finish_Moment-Mpi_Start_Moment<<"\n"; pSaveFile.close(); }
void Workspace::RemoveFile(QString projectName, QString file, bool isExternal) { Project * project = FindProject(projectName); if (project == NULL) { return; } QString msg; QString fullPath = GetFullFilePath(projectName, file); if (isExternal) { msg = "Confirm removing reference to this external file?\nThe file will NOT be deleted!\n\n" + file; } else { msg = "Confirm deleting this file: \n\n" + fullPath; } if (GetUserConfirmation(msg) == false) { return; } int index = -1; for (int i=0; i < project->files.size(); i++) { if (isExternal) { if ( (project->files.at(i).type == ptExternal) && (project->files.at(i).name == file) ) { index = i; break; } } else { if ( (project->files.at(i).type == ptSource) && (project->files.at(i).name == file) ) { index = i; break; } } } if (index < 0 ) { ErrorMessage("Could not delete the file!\n"); return; } if (isExternal == false) { bool ok = QFile(fullPath).remove(); if (ok == false) { ErrorMessage("Error deleting the file!\n"); return; } } project->files.erase(project->files.begin() + index); modified = true; }
void Workspace::RenameFile(QString projectName, QString file) { Project * project = FindProject(projectName); if (project == NULL) { return; } int index = -1; for (int i=0; i < project->files.size(); i++) { if ( (project->files.at(i).type != ptExternal) && (project->files.at(i).name == file) ) { index = i; break; } } if (index < 0 ) { ErrorMessage("Could not rename the file!\n"); return; } GetUserString * user = new GetUserString(); QString newName = user->GetNewName(QFileInfo(file).baseName(), true); if (newName == "") { return; } QString ext = QFileInfo(file).suffix(); newName = QFileInfo(newName).baseName(); newName = config.workspace + "/" + project->name + "/source/" + newName + "." + ext; QString oldName = GetFullFilePath(projectName, file); if (QFile(oldName).rename(newName) == false) { ErrorMessage("Error while renaming the file!\n"); return; } project->files.at(index).name = QFileInfo(newName).fileName(); modified = true; }