static PtrT ReadFileToCustomMemory(const StrT fileName, uint32_t memFlags) { BPTR fh; PtrT data = NULL; PtrT path = AbsPath(fileName); if ((fh = Open(path, MODE_OLDFILE))) { struct FileInfoBlock *infoBlock; if ((infoBlock = (struct FileInfoBlock *) AllocDosObject(DOS_FIB, NULL))) { if (ExamineFH(fh, infoBlock)) { size_t dataLen = infoBlock->fib_Size; if ((data = MemNewCustom(dataLen, memFlags, NULL))) { if (dataLen != Read(fh, data, dataLen)) { MemUnref(data); data = NULL; } } } FreeDosObject(DOS_FIB, infoBlock); } Close(fh); } MemUnref(path); return data; }
void CChordEaseApp::MakeAbsolutePath(CString& Path) { if (PathIsRelative(Path)) { // if path is relative CPathStr AbsPath(GetDataFolderPath()); AbsPath.Append(Path); Path = AbsPath; } }
void WriteFileSimple(const StrT fileName, PtrT data, size_t length) { BPTR fh; PtrT path = AbsPath(fileName); if ((fh = Open(path, MODE_NEWFILE))) { Write(fh, data, length); Close(fh); } }
void CChordEaseApp::ValidateFolder(CDataExchange* pDX, int CtrlID, const CString& Path) { if (pDX->m_bSaveAndValidate) { CString msg; if (Path.IsEmpty()) // if path is empty msg.LoadString(IDS_APP_FOLDER_REQUIRED); else { CString AbsPath(Path); theApp.MakeAbsolutePath(AbsPath); if (!PathFileExists(AbsPath)) // if path doesn't exist AfxFormatString1(msg, IDS_APP_FOLDER_NOT_FOUND, AbsPath); } if (!msg.IsEmpty()) { AfxMessageBox(msg); DDV_Fail(pDX, CtrlID); } } }
bool HasEntry(const wxString & path) const { return m_items.find(AbsPath(path)) != m_items.end(); }
void SetPath(const wxString & path) { m_path = AbsPath(path); }