本文整理汇总了C++中PathName::RemoveFileSpec方法的典型用法代码示例。如果您正苦于以下问题:C++ PathName::RemoveFileSpec方法的具体用法?C++ PathName::RemoveFileSpec怎么用?C++ PathName::RemoveFileSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathName
的用法示例。
在下文中一共展示了PathName::RemoveFileSpec方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPathName
PathName
DviDoc::GetDocDir ()
{
PathName result = GetPathName();
result.RemoveFileSpec ();
return (result);
}
示例2: destDir
void
File::Move (/*[in]*/ const PathName & source,
/*[in]*/ const PathName & dest)
{
struct stat sourceStat;
if (stat(source.Get(), &sourceStat) != 0)
{
FATAL_CRT_ERROR ("stat", source.Get());
}
PathName destDir (dest);
destDir.MakeAbsolute ();
destDir.RemoveFileSpec ();
struct stat destStat;
if (stat(destDir.Get(), &destStat) != 0)
{
FATAL_CRT_ERROR ("stat", destDir.Get());
}
bool sameDevice = (sourceStat.st_dev == destStat.st_dev);
if (sameDevice)
{
SessionImpl::theSession->trace_files->WriteFormattedLine
("core",
T_("renaming %s to %s"),
Q_(source),
Q_(dest));
if (rename(source.Get(), dest.Get()) != 0)
{
FATAL_CRT_ERROR ("rename", source.Get());
}
}
else
{
Copy (source, dest);
try
{
Delete (source);
}
catch (const MiKTeXException &)
{
try
{
if (Exists(source))
{
Delete (dest);
}
}
catch (const MiKTeXException &)
{
}
throw;
}
}
}
示例3: if
FILE *
File::Open (/*[in]*/ const PathName & path,
/*[in]*/ FileMode mode,
/*[in]*/ FileAccess access,
/*[in]*/ bool isTextFile,
/*[in]*/ FileShare share)
{
UNUSED_ALWAYS (isTextFile);
UNUSED_ALWAYS (share);
SessionImpl::theSession->trace_files->WriteFormattedLine
("core",
T_("opening file %s (%d 0x%x %d %d)"),
Q_(path),
static_cast<int>(mode.Get()),
static_cast<int>(access.Get()),
static_cast<int>(share.Get()),
static_cast<int>(isTextFile));
int flags = 0;
string strFlags;
if (mode == FileMode::Create)
{
flags |= O_CREAT;
}
else if (mode == FileMode::Append)
{
flags |= O_APPEND;
}
if (access == FileAccess::ReadWrite)
{
flags |= O_RDWR;
if (mode == FileMode::Append)
{
strFlags += "a+";
}
else
{
strFlags += "r+";
}
}
else if (access == FileAccess::Read)
{
flags |= O_RDONLY;
strFlags += "r";
}
else if (access == FileAccess::Write)
{
flags |= O_WRONLY;
if (mode == FileMode::Append)
{
strFlags += "a";
}
else
{
flags |= O_TRUNC;
strFlags += "w";
}
}
if (mode == FileMode::Create)
{
PathName dir (path);
dir.MakeAbsolute ();
dir.RemoveFileSpec();
if (! Directory::Exists(dir))
{
Directory::Create (dir);
}
}
int fd;
fd =
open(path.Get(),
flags,
(((flags & O_CREAT) == 0)
? 0
: (0
| S_IRUSR | S_IWUSR
| S_IRGRP
| S_IROTH
| 0)));
if (fd < 0)
{
FATAL_CRT_ERROR ("open", path.Get());
}
try
{
return (FdOpen(fd, strFlags.c_str()));
}
catch (const exception &)
{
close (fd);
throw;
}
//.........这里部分代码省略.........
示例4: documentLocation
bool
DviImpl::FindSource (/*[in]*/ const char * lpszFileName,
/*[in]*/ int line,
/*[out]*/ DviPosition & position)
{
CheckCondition ();
MIKTEX_BEGIN_CRITICAL_SECTION (&criticalSectionMonitor)
{
trace_search->WriteFormattedLine
("libdvi",
T_("searching src special %d %s"),
line,
lpszFileName);
SourceSpecial * pSourceSpecial1Best = 0;
SourceSpecial * pSourceSpecial2Best = 0;
int pageIdx1 = -1;
int pageIdx2 = -1;
// get fully qualified path to the directory location of the
// document
PathName documentLocation (fqDviFileName);
documentLocation.RemoveFileSpec ();
// file name relative to the location of the DVI document
const char * lpszRelFileName;
// absolute file name
PathName fqFileName;
if (Utils::IsAbsolutePath(lpszFileName))
{
lpszRelFileName =
Utils::GetRelativizedPath(lpszFileName, documentLocation.Get());
fqFileName = lpszFileName;
fqFileName.MakeAbsolute ();
}
else
{
lpszRelFileName = lpszFileName;
fqFileName = documentLocation;
fqFileName += lpszFileName;
fqFileName.MakeAbsolute ();
}
//
// scan the document
//
for (int pageIdx = 0; pageIdx < GetNumberOfPages(); ++ pageIdx)
{
DviPageImpl * pPage;
try
{
pPage = reinterpret_cast<DviPageImpl*>(GetLoadedPage(pageIdx));
}
catch (const OperationCancelledException &)
{
return (false);
}
if (pPage == 0)
{
throw DviPageNotFoundException
(0,
T_("The DVI page could not be found."),
0,
__FILE__,
__LINE__);
}
AutoUnlockPage autoUnlockPage (pPage);
SourceSpecial * pSourceSpecial1 = 0;
SourceSpecial * pSourceSpecial2 = 0;
SourceSpecial * pSourceSpecial;
for (int j = -1;
(pSourceSpecial = pPage->GetNextSpecial<SourceSpecial>(j)) != 0;
)
{
const char * lpszName = pSourceSpecial->GetFileName();
// try exact match
bool nameMatch =
(MyPathNameCompare(lpszName, lpszFileName) == 0);
// try fully qualified file names
if (! nameMatch)
{
PathName fqName;
if (Utils::IsAbsolutePath(lpszName))
{
fqName = lpszName;
fqName.MakeAbsolute ();
}
//.........这里部分代码省略.........
示例5: if
bool
PostScript::FindGraphicsFile (/*[in]*/ const char * lpszFileName,
/*[out]*/ PathName & result)
{
if (*lpszFileName == '`')
{
if (pDviImpl->TryGetTempFile(lpszFileName, result))
{
return (true);
}
else if (strncmp(lpszFileName + 1, "gunzip -c ", 10) == 0)
{
Uncompress (lpszFileName + 11, result);
return (true);
}
else if (strncmp(lpszFileName + 1, "bunzip2 -c ", 11) == 0)
{
Uncompress (lpszFileName + 12, result);
return (true);
}
else if (! AllowShellCommand(lpszFileName + 1))
{
tracePS->WriteFormattedLine ("libdvi", T_("Ignoring shell command %s"), Q_(lpszFileName + 1));
return (false);
}
else
{
char szTempFileName[_MAX_PATH];
Utils::CopyString (szTempFileName,
_MAX_PATH,
PathName().SetToTempFile().Get());
string command;
command = lpszFileName + 1;
command += " > ";
command += Q_(szTempFileName);
MIKTEX_ASSERT (pDviImpl != 0);
PathName docDir = pDviImpl->GetDviFileName();
docDir.RemoveFileSpec();
StdoutReader reader;
bool done =
Process::ExecuteSystemCommand(command.c_str(), 0,
&reader, docDir.Get());
if (! done)
{
// <fixme>hard-coded string</fixme>
File::Delete (szTempFileName);
FATAL_MIKTEX_ERROR ("PostScript::FindGraphicsFile",
T_("Execution of an embedded shell ")
T_("command failed for some reason!"),
0);
}
pDviImpl->RememberTempFile (lpszFileName + 1, szTempFileName);
result = szTempFileName;
return (true);
}
}
else if (IsZFileName(lpszFileName))
{
if (pDviImpl->TryGetTempFile(lpszFileName, result))
{
return (true);
}
Uncompress (lpszFileName, result);
return (true);
}
else
{
return (pDviImpl->FindGraphicsFile(lpszFileName, result));
}
}