HRESULT CFileHelper::WriteText(LPCTSTR path, LPCTSTR text) { BOOL exists = FALSE; HRESULT hr = Contains(path, exists); if(FAILED(hr)) return hr; if( !exists) { String folder ; if(SUCCEEDED( GetParentFolder(path, folder))) { hr = CreateFolder(folder.c_str()); if(FAILED(hr)) return hr; } } FileOutputStream ofs; ofs.imbue(locale("chs")); ofs.open(path); if(!ofs.is_open()) return E_FAIL; ofs.clear(); ofs.write(text, STRLEN(text)/* *sizeof(TCHAR)*/); ofs.close(); return S_OK; }
HRESULT CFileHelper::WriteBytes(LPCTSTR path, int count,const BYTE * bytes) { BOOL exists = FALSE; HRESULT hr = Contains(path, exists); if(FAILED(hr)) return hr; if( !exists) { String folder ; if(SUCCEEDED(GetParentFolder(path, folder))) { hr = CreateFolder(folder.c_str()); if(FAILED(hr)) return hr; } } ofstream ofs; ofs.open(path); if(!ofs.is_open()) return E_FAIL; ofs.clear(); if(bytes) ofs.write((const char *)bytes,(int)count); ofs.close(); return S_OK; }
// ------------------------------------------------------------------------- // // * GetPath( void ) // ------------------------------------------------------------------------- // TDCLNSRef TDCLFSItem::GetPath( void ) { TDCLNSRef thePath = GetParentFolder()->GetPath(); // Ajout de cet ŽlŽment. thePath.ToArray().Add( ToFrame() ); return thePath; }
/** Base class pure virtual. @internalTechnology @test @param None @return EPass or EFail indicating the result of the test step. */ TVerdict CTestUpdateVisitedStep::doTestStepL() { TInt error = KErrNone; RBkFolder parentFolder; if ((error = GetParentFolder(KMainTestFolder(), parentFolder)) != KErrNone) { ERR_PRINTF3(_L("Error %D occured while opening parent folder %S"), error, &(KMainTestFolder())); SetTestStepResult(EFail); } else { CleanupClosePushL(parentFolder); RBkBookmark bookmark = iBkDb.CreateBookmarkL(&parentFolder); CleanupClosePushL(bookmark); DoTest(bookmark); DoTest(bookmark); iBkDb.DeleteItemL(bookmark.Id()); CleanupStack::PopAndDestroy(2, &parentFolder); } return TestStepResult(); } // doTestStepL
HRESULT CFileHelper::CreateFolder(LPCTSTR path) { BOOL b= FALSE; HRESULT hr = Contains(path, b); if(FAILED(hr)) return hr; if(b) return S_FALSE; String parent; hr = GetParentFolder(path, parent); if(FAILED(hr)) return hr; hr = CreateFolder(parent.c_str()); if(FAILED(hr)) return hr; #ifdef UNICODE return _wmkdir(path) == 0 ? S_OK : E_FAIL; #else return _mkdir(path) == 0 ? S_OK : E_FAIL; #endif }