本文整理汇总了C++中PathName类的典型用法代码示例。如果您正苦于以下问题:C++ PathName类的具体用法?C++ PathName怎么用?C++ PathName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PathName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ERROR3
void OpConvertFileFormats::Do(OpDescriptor*)
{
ERROR3 ("Please read the following comments BEFORE using this op!"); // comment this out to use the op
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// set up the search path, file util allows us just to pass the path/*.xar
String_256 SearchPath = TEXT ("d:\\clipart\\xara\\"); // YOU MUST CHANGE THIS PATH
String_256 FileSpecifier = SearchPath; // YOU MUST CHANGE THIS EXTENSION
FileSpecifier += TEXT("*.art");
String_256 FileSpecifier2 = TEXT("xar"); // YOU MUST CHANGE THIS EXTENSION
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL ok = FileUtil::StartFindingFiles(&FileSpecifier);
active = TRUE;
String_256 Filename;
while (ok)
{
// fileutil will give us the next filename
ok = FileUtil::FindNextFile(&Filename);
String_256 FilePath = SearchPath;
FilePath += Filename;
PathName Path (FilePath);
if (ok)
{
CDocument* pDoc = theApp.OpenDocumentFile((TCHAR*)FilePath);
if (pDoc!=NULL)
{
// Make sure that the files name is sensible
theApp.MakeDocumentNative(pDoc, &Path);
Path.SetType (FileSpecifier2);
String_256 newPath = Path.GetPath ();
pDoc->DoSave ((TCHAR*) newPath, TRUE);
FileCloseAction ();
}
}
}
active = FALSE;
FileUtil::StopFindingFiles ();
}
示例2: GetPackageInfo
bool PackageManagerImpl::TryVerifyInstalledPackage(const string& packageId)
{
PackageInfo packageInfo = GetPackageInfo(packageId);
PathName prefix;
if (!session->IsAdminMode() && IsValidTimeT(packageInfo.timeInstalledByUser))
{
prefix = session->GetSpecialPath(SpecialPath::UserInstallRoot);
}
if (prefix.Empty())
{
prefix = session->GetSpecialPath(SpecialPath::CommonInstallRoot);
}
FileDigestTable fileDigests;
if (!TryCollectFileDigests(prefix, packageInfo.runFiles, fileDigests)
|| !TryCollectFileDigests(prefix, packageInfo.docFiles, fileDigests)
|| !TryCollectFileDigests(prefix, packageInfo.sourceFiles, fileDigests))
{
return false;
}
MD5Builder md5Builder;
for (const pair<string, MD5> p : fileDigests)
{
PathName path(p.first);
// we must dosify the path name for backward compatibility
path.ConvertToDos();
md5Builder.Update(path.GetData(), path.GetLength());
md5Builder.Update(p.second.data(), p.second.size());
}
bool ok = md5Builder.Final() == packageInfo.digest;
if (!ok)
{
trace_mpm->WriteLine(TRACE_FACILITY, fmt::format(T_("package {0} verification failed: some files have been modified"), Q_(packageId)));
trace_mpm->WriteLine(TRACE_FACILITY, fmt::format(T_("expected digest: {0}"), packageInfo.digest));
trace_mpm->WriteLine(TRACE_FACILITY, fmt::format(T_("computed digest: {0}"), md5Builder.GetMD5()));
}
return ok;
}
示例3: miktex_find_miktex_executable
miktex_find_miktex_executable (/*[in]*/ const char * lpszExeName,
/*[out]*/ char * lpszExePath)
{
C_FUNC_BEGIN ();
MIKTEX_ASSERT_STRING (lpszExeName);
MIKTEX_ASSERT_PATH_BUFFER (lpszExePath);
PathName temp;
if (! SessionImpl::GetSession()->FindFile(lpszExeName,
FileType::EXE,
temp))
{
return (0);
}
Utils::CopyString (lpszExePath, BufferSizes::MaxPath, temp.Get());
return (1);
C_FUNC_END ();
}
示例4: clear
void ParsedPath::parse(const PathName& path)
{
clear();
if (path.length() == 1) {
add(path);
return;
}
PathName oldpath = path;
do {
PathName newpath, elem;
PathUtils::splitLastComponent(newpath, elem, oldpath);
oldpath = newpath;
insert(0, elem);
} while (oldpath.length() > 0);
}
示例5: hasSeparator
// Checks that argument doesn't contain colon or directory separator
static inline bool hasSeparator(const PathName& name)
{
for (const char* p = name.c_str(); *p; p++)
{
if (*p == ':' || *p == '/' || *p == '\\')
return true;
}
return false;
}
示例6: SupportsHardLinks
bool Utils::SupportsHardLinks(const PathName& path)
{
DWORD fileSystemFlags;
wchar_t fileSystemName[_MAX_PATH];
PathName root = path.GetMountPoint();
if (GetVolumeInformationW(root.ToWideCharString().c_str(), nullptr, 0, nullptr, nullptr, &fileSystemFlags, fileSystemName, _MAX_PATH) == 0)
{
MIKTEX_FATAL_WINDOWS_ERROR_2("GetVolumeInformationW", "root", root.ToString());
}
if (WindowsVersion::IsWindows7OrGreater())
{
return (fileSystemFlags & FILE_SUPPORTS_HARD_LINKS) != 0;
}
else
{
return _wcsicmp(fileSystemName, L"NTFS") == 0;
}
}
示例7: SetAuxDirectory
void WebAppInputLine::SetAuxDirectory(const PathName& path)
{
if (pimpl->auxDirectory == path)
{
return;
}
LogInfo("setting aux directory: " + path.ToString());
pimpl->auxDirectory = path;
}
示例8: makeRelativeTo
bool PathName::makeRelativeTo(const PathName& root)
{
mDebugAssert(root.getPath() != NULL);
mDebugAssert(mRelativePath != NULL);
if (!isChildOf(root))
{
return false;
}
mRelativePath = mRelativePath + root.getPathLength();
if (*mRelativePath != '\0')
{
// Move beyond path separator
mRelativePath++;
}
return true;
}
示例9: MakeNTEmacsClientCommandLine
bool
MakeNTEmacsClientCommandLine (/*[out]*/ string & program,
/*[out]*/ string & arguments)
{
PathName pathEmacs;
if (! LocateNTEmacs(pathEmacs, "gnuclientw.exe"))
{
wchar_t szEmacs[_MAX_PATH];
wchar_t * lpszFileName;
if (! SearchPathW(0, L"gnuclientw.exe", 0, _MAX_PATH, szEmacs, &lpszFileName))
{
return (false);
}
pathEmacs = szEmacs;
}
program = pathEmacs.Get();
arguments = "-F +%l \"%f\"";
return (true);
}
示例10: defined
void
CommandLineBuilder::AppendStdinRedirection (/*[in]*/ const char * lpszPath)
{
pData->str += '<';
#if defined(MIKTEX_WINDOWS)
PathName dosish (lpszPath);
lpszPath = dosish.ToDos().Get();
#endif
bool needsQuoting = (StrChr(lpszPath, ' ') != 0);
if (needsQuoting)
{
pData->str += '"';
}
pData->str += lpszPath;
if (needsQuoting)
{
pData->str += '"';
}
}
示例11: LocateNTEmacs
bool
LocateNTEmacs (/*[out]*/ PathName & ntEmacs,
/*[in]*/ const char * lpszName)
{
PathName path;
if (! ReadPath(HKEY_LOCAL_MACHINE, L"SOFTWARE\\GNU\\Emacs", L"emacs_dir", path))
{
return (false);
}
path += "bin";
path += lpszName;
path.SetExtension (".exe");
if (! File::Exists(path))
{
return (false);
}
ntEmacs = path;
return (true);
}
示例12: raw_devices_unlink_database
static int raw_devices_unlink_database(const PathName& file_name)
{
char header[MIN_PAGE_SIZE];
int desc = -1;
for (int i = 0; i < IO_RETRY; i++)
{
if ((desc = open (file_name.c_str(), O_RDWR | O_BINARY)) != -1)
break;
if (!SYSCALL_INTERRUPTED(errno))
{
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("open") << Arg::Str(file_name) <<
Arg::Gds(isc_io_open_err) << Arg::Unix(errno));
}
}
memset(header, 0xa5, sizeof(header));
int i;
for (i = 0; i < IO_RETRY; i++)
{
const ssize_t bytes = write (desc, header, sizeof(header));
if (bytes == sizeof(header))
break;
if (bytes == -1 && SYSCALL_INTERRUPTED(errno))
continue;
ERR_post(Arg::Gds(isc_io_error) << Arg::Str("write") << Arg::Str(file_name) <<
Arg::Gds(isc_io_write_err) << Arg::Unix(errno));
}
//if (desc != -1) perhaps it's better to check this???
close(desc);
#ifdef DEV_BUILD
gds__log ("raw_devices_unlink_database: %s -> %s\n",
file_name.c_str(), i < IO_RETRY ? "true" : "false");
#endif
return 0;
}
示例13: TRACE1
void OpGenericDownload::OnDownloadSuccess()
{
// get a pointer to the OpParam so that I can retrieve some useful information
GenericDownloadParam* pGenericParam = (GenericDownloadParam*) pParam;
String_256 GenericFile = (pGenericParam->file).GetFileName();
if (IsUserName("Olivier"))
TRACE1("OpGenericDownload::OnDownloadSuccess(), file = %s\n", (TCHAR*)GenericFile);
Filter* pFilter = pGenericParam->m_pFilter;
PathName Path = pGenericParam->file;
String_256 URL = pGenericParam->strURL;
SelOperation* Op = pGenericParam->m_Op;
// call the DoImport function from OpMenuImport class
((OpMenuImport*)Op)->DoImport(Path, pFilter, &URL);
// remove the temporary file
remove((TCHAR*) (String_256) Path.GetPath());
}
示例14: Save
BOOL OpMenuSave::Save ( Filter *pFilter, CCLexFile *pFile )
{
// Check that the extension is ok according to this filter
// But only if the operation requires it
if (FixFileType())
{
PathName pth = pFile->GetPathName();
if (pth.IsValid()) EnsureFileTypeCorrectId(pFilter, pth);
}
// open the file and export into it
if (!SaveSpecificFile(pFilter, pFile))
{
FailAndExecute();
return FALSE;
}
// Success.
return TRUE;
}
示例15: ReadDirectory
bool PackageManagerImpl::ReadDirectory(const PathName& path, vector<string>& subDirNames, vector<string>& fileNames, vector<string>& fileNameInfos)
{
const DirectoryInfo& directoryInfo = directoryInfoTable[path.ToString()];
for (const string& name : directoryInfo.subDirectoryNames)
{
subDirNames.push_back(name);
}
fileNames = directoryInfo.fileNames;
fileNameInfos = directoryInfo.packageNames;
return true;
}