本文整理匯總了C++中GetLocalPath函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetLocalPath函數的具體用法?C++ GetLocalPath怎麽用?C++ GetLocalPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetLocalPath函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetLocalPath
bool DirectoryFileSystem::RemoveFile(const std::string &filename) {
std::string fullName = GetLocalPath(filename);
#ifdef _WIN32
bool retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
#else
bool retValue = (0 == unlink(fullName.c_str()));
#endif
#if HOST_IS_CASE_SENSITIVE
if (! retValue)
{
// May have failed due to case sensitivity, so try again
fullName = filename;
if ( ! FixPathCase(basePath,fullName, FPC_FILE_MUST_EXIST) )
return false; // or go on and attempt (for a better error code than just false?)
fullName = GetLocalPath(fullName);
#ifdef _WIN32
retValue = (::DeleteFileA(fullName.c_str()) == TRUE);
#else
retValue = (0 == unlink(fullName.c_str()));
#endif
}
#endif
return retValue;
}
示例2: GetLocalPath
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
PSPFileInfo x;
x.name = filename;
std::string fullName = GetLocalPath(filename);
if (! File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
if (! FixPathCase(basePath,filename, FPC_FILE_MUST_EXIST))
return x;
fullName = GetLocalPath(filename);
if (! File::Exists(fullName))
return x;
#else
return x;
#endif
}
x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
x.exists = true;
if (x.type != FILETYPE_DIRECTORY)
{
struct stat s;
stat(fullName.c_str(), &s);
x.size = File::GetSize(fullName);
x.access = s.st_mode & 0x1FF;
localtime_r((time_t*)&s.st_atime,&x.atime);
localtime_r((time_t*)&s.st_ctime,&x.ctime);
localtime_r((time_t*)&s.st_mtime,&x.mtime);
}
return x;
}
示例3: GetLocalPath
int DirectoryFileSystem::RenameFile(const std::string &from, const std::string &to) {
std::string fullTo = to;
// Rename ignores the path (even if specified) on to.
size_t chop_at = to.find_last_of('/');
if (chop_at != to.npos)
fullTo = to.substr(chop_at + 1);
// Now put it in the same directory as from.
size_t dirname_end = from.find_last_of('/');
if (dirname_end != from.npos)
fullTo = from.substr(0, dirname_end + 1) + fullTo;
// At this point, we should check if the paths match and give an already exists error.
if (from == fullTo)
return SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS;
std::string fullFrom = GetLocalPath(from);
#if HOST_IS_CASE_SENSITIVE
// In case TO should overwrite a file with different case
if ( ! FixPathCase(basePath,fullTo, FPC_PATH_MUST_EXIST) )
return -1; // or go on and attempt (for a better error code than just false?)
#endif
fullTo = GetLocalPath(fullTo);
const char * fullToC = fullTo.c_str();
#ifdef _WIN32_NO_MINGW
bool retValue = (MoveFile(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str()) == TRUE);
#else
bool retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif
#if HOST_IS_CASE_SENSITIVE
if (! retValue)
{
// May have failed due to case sensitivity on FROM, so try again
fullFrom = from;
if ( ! FixPathCase(basePath,fullFrom, FPC_FILE_MUST_EXIST) )
return -1; // or go on and attempt (for a better error code than just false?)
fullFrom = GetLocalPath(fullFrom);
#ifdef _WIN32_NO_MINGW
retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE);
#else
retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif
}
#endif
// TODO: Better error codes.
return retValue ? 0 : (int)SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS;
}
示例4: MkDir
bool DirectoryFileSystem::MkDir(const std::string &dirname) {
#if HOST_IS_CASE_SENSITIVE
// Must fix case BEFORE attempting, because MkDir would create
// duplicate (different case) directories
std::string fixedCase = dirname;
if ( ! FixPathCase(basePath,fixedCase, FPC_PARTIAL_ALLOWED) )
return false;
return File::CreateFullPath(GetLocalPath(fixedCase));
#else
return File::CreateFullPath(GetLocalPath(dirname));
#endif
}
示例5: GetLocalPath
NS_IMETHODIMP nsPop3IncomingServer::MarkMessages()
{
nsresult rv;
if (m_runningProtocol)
rv = m_runningProtocol->MarkMessages(&m_uidlsToMark);
else
{
nsCString hostName;
nsCString userName;
nsCOMPtr<nsIFile> localPath;
GetLocalPath(getter_AddRefs(localPath));
GetHostName(hostName);
GetUsername(userName);
// do it all in one fell swoop
rv = nsPop3Protocol::MarkMsgForHost(hostName.get(), userName.get(), localPath, m_uidlsToMark);
}
uint32_t count = m_uidlsToMark.Length();
for (uint32_t i = 0; i < count; i++)
{
Pop3UidlEntry *ue = m_uidlsToMark[i];
PR_Free(ue->uidl);
PR_Free(ue);
}
m_uidlsToMark.Clear();
return rv;
}
示例6: handleDirectoriesToSyncUpdated
void SyncManager::handleDirectoriesToSyncUpdated (const QList<SyncerInfo>& infos)
{
QStringList paths;
for (const auto& info : infos)
{
paths << info.LocalDirectory_;
auto acc = AM_->GetAccountFromUniqueID (info.AccountId_);
if (AccountID2Syncer_.contains (info.AccountId_))
{
auto syncer = AccountID2Syncer_ [info.AccountId_];
if (syncer->GetLocalPath () == info.LocalDirectory_ &&
syncer->GetRemotePath () == info.RemoteDirectory_)
continue;
else
{
//TODO update syncer
// syncer->stop ();
// AccountID2Syncer_.take (info.AccountId_)->deleteLater ();
}
}
else
{
auto syncer = CreateSyncer (acc, info.LocalDirectory_, info.RemoteDirectory_);
AccountID2Syncer_ [info.AccountId_] = syncer;
// syncer->start ();
}
}
FilesWatcher_->updatePaths (paths);
}
示例7: ERROR_LOG
u32 VFSFileSystem::OpenFile(std::string filename, FileAccess access, const char *devicename) {
if (access != FILEACCESS_READ) {
ERROR_LOG(FILESYS, "VFSFileSystem only supports plain reading");
return 0;
}
std::string fullName = GetLocalPath(filename);
const char *fullNameC = fullName.c_str();
DEBUG_LOG(FILESYS,"VFSFileSystem actually opening %s (%s)", fullNameC, filename.c_str());
size_t size;
u8 *data = VFSReadFile(fullNameC, &size);
if (!data) {
ERROR_LOG(FILESYS, "VFSFileSystem failed to open %s", filename.c_str());
return 0;
}
OpenFileEntry entry;
entry.fileData = data;
entry.size = size;
entry.seekPos = 0;
u32 newHandle = hAlloc->GetNewHandle();
entries[newHandle] = entry;
return newHandle;
}
示例8: GetLocalPath
bool DirectoryFileSystem::MkDir(const std::string &dirname)
{
std::string fullName = GetLocalPath(dirname);
return File::CreateFullPath(fullName);
}
示例9: ASSERT
ERMsg CDirectoryManagerBase::Import(const std::string& filePath, const std::string& fileExt)const
{
ASSERT(!filePath.empty());
ASSERT(m_bHaveLocalPath);
ASSERT(!m_localPath.empty());
ERMsg msg;
if (!GetLocalPath().empty())
{
ASSERT(false);
//std::string newName = GetLocalPath() + UtilWin::GetFileTitle( filePath ) + fileExt;
//if( !DirExist(GetLocalPath()) )
//{
// if( !CreateMultipleDir( GetLocalPath() ) )
// {
// msg.asgType(ERMsg::ERREUR);
// return msg;
// }
//}
//if( !::CopyFile( filePath, newName, true) )
// {
// msg = SYGetMessage( GetLastError() );
// std::string erreur;
// erreur.FormatMsg(IDS_CMN_FILENOTIMPORT, (LPCTSTR)filePath, (LPCTSTR)GetLocalPath() );
// msg.ajoute(erreur);
// }
}
return msg;
}
示例10: DepotMatchingRepositoryListener
status_t
ServerRepositoryDataUpdateProcess::ProcessLocalData()
{
DepotMatchingRepositoryListener* itemListener =
new DepotMatchingRepositoryListener(fModel, this);
ObjectDeleter<DepotMatchingRepositoryListener>
itemListenerDeleter(itemListener);
BulkContainerDumpExportRepositoryJsonListener* listener =
new BulkContainerDumpExportRepositoryJsonListener(itemListener);
ObjectDeleter<BulkContainerDumpExportRepositoryJsonListener>
listenerDeleter(listener);
BPath localPath;
status_t result = GetLocalPath(localPath);
if (result != B_OK)
return result;
result = ParseJsonFromFileWithListener(listener, localPath);
if (result != B_OK)
return result;
return listener->ErrorStatus();
}
示例11: GetLocalPath
bool DirectoryFileSystem::RmDir(const std::string &dirname)
{
std::string fullName = GetLocalPath(dirname);
#ifdef _WIN32
return RemoveDirectory(fullName.c_str()) == TRUE;
#else
return 0 == rmdir(fullName.c_str());
#endif
}
示例12: SetLocalCurrentDir
//=============================================================================
// 函數名稱: 設置當前工作目錄
// 作者說明: mushuai
// 修改時間: 2010-03-08
//=============================================================================
BOOL SetLocalCurrentDir()
{
CString path=GetLocalPath();
path+='\\';
DWORD dwret=SetCurrentDirectory(path.GetBuffer(0));
if (dwret==0)
return FALSE;
return TRUE;
}
示例13: GetLocalPath
PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
PSPFileInfo x;
x.name = filename;
std::string fullName = GetLocalPath(filename);
if (!File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
if (! FixPathCase(basePath,filename, FPC_FILE_MUST_EXIST))
return x;
fullName = GetLocalPath(filename);
if (! File::Exists(fullName))
return x;
#else
return x;
#endif
}
x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
x.exists = true;
if (x.type != FILETYPE_DIRECTORY) {
File::FileDetails details;
if (!File::GetFileDetails(fullName, &details)) {
ERROR_LOG(FILESYS, "DirectoryFileSystem::GetFileInfo: GetFileDetails failed: %s", fullName.c_str());
x.size = 0;
x.access = 0;
memset(&x.atime, 0, sizeof(x.atime));
memset(&x.ctime, 0, sizeof(x.ctime));
memset(&x.mtime, 0, sizeof(x.mtime));
} else {
x.size = details.size;
x.access = details.access;
time_t atime = details.atime;
time_t ctime = details.ctime;
time_t mtime = details.mtime;
localtime_r((time_t*)&atime, &x.atime);
localtime_r((time_t*)&ctime, &x.ctime);
localtime_r((time_t*)&mtime, &x.mtime);
}
}
return x;
}
示例14: return
int VirtualDiscFileSystem::getFileListIndex(std::string &fileName)
{
std::string normalized;
if (fileName.length() >= 1 && fileName[0] == '/') {
normalized = fileName.substr(1);
} else {
normalized = fileName;
}
for (size_t i = 0; i < fileList.size(); i++)
{
if (fileList[i].fileName == normalized)
return (int)i;
}
// unknown file - add it
std::string fullName = GetLocalPath(fileName);
if (! File::Exists(fullName)) {
#if HOST_IS_CASE_SENSITIVE
if (! FixPathCase(basePath,fileName, FPC_FILE_MUST_EXIST))
return -1;
fullName = GetLocalPath(fileName);
if (! File::Exists(fullName))
return -1;
#else
return -1;
#endif
}
FileType type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL;
if (type == FILETYPE_DIRECTORY)
return -1;
FileListEntry entry = {""};
entry.fileName = normalized;
entry.totalSize = File::GetFileSize(fullName);
entry.firstBlock = currentBlockIndex;
currentBlockIndex += (entry.totalSize+2047)/2048;
fileList.push_back(entry);
return (int)fileList.size()-1;
}
示例15: localFile
/*----------------------------------------------------------------------
Save an opened document to a specified path in order to open.
The parameter doc is the original doc to be saved
The parameter newdoc is the new document
The parameter newpath is the newdoc URI
Return the saved localFile (to be freed) or NULL
----------------------------------------------------------------------*/
char *SaveDocumentToNewDoc(Document doc, Document newdoc, char* newpath)
{
ElementType elType;
Element root;
char *localFile = NULL, *s;
ThotBool res = FALSE;
localFile = GetLocalPath (newdoc, newpath);
// apply link changes to the template
TtaOpenUndoSequence (doc, NULL, NULL, 0, 0);
SetRelativeURLs (doc, newpath, NULL, FALSE, FALSE, FALSE, FALSE);
// prepare the new document view
TtaExtractName (newpath, DirectoryName, DocumentName);
root = TtaGetRootElement(doc);
elType = TtaGetElementType (root);
// get the target document type
s = TtaGetSSchemaName (elType.ElSSchema);
if (!IsNotHTMLorHTML5 (s))
{
if (TtaGetDocumentProfile(doc) == L_HTML5 || TtaGetDocumentProfile(doc) == L_HTML5_LEGACY)
res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "HTML5TX", FALSE);
else
{
/* docType = docHTML; */
if (TtaGetDocumentProfile(doc) == L_Xhtml11 ||
TtaGetDocumentProfile(doc) == L_Basic)
res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "HTMLT11", FALSE);
else
res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "HTMLTX", FALSE);
}
}
else if (strcmp (s, "SVG") == 0)
/* docType = docSVG; */
res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "SVGT", FALSE);
else if (strcmp (s, "MathML") == 0)
/* docType = docMath; */
res = TtaExportDocumentWithNewLineNumbers (doc, localFile, "MathMLT", FALSE);
else
/* docType = docXml; */
res = TtaExportDocumentWithNewLineNumbers (doc, localFile, NULL, FALSE);
// restore the previous state of the template
TtaCloseUndoSequence (doc);
TtaUndoNoRedo (doc);
if (res)
return localFile;
else
{
TtaFreeMemory (localFile);
return NULL;
}
}