本文整理汇总了C++中FileName::absFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::absFileName方法的具体用法?C++ FileName::absFileName怎么用?C++ FileName::absFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::absFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readWithoutConv
TextClass::ReturnValues TextClass::readWithoutConv(FileName const & filename, ReadType rt)
{
if (!filename.isReadableFile()) {
lyxerr << "Cannot read layout file `" << filename << "'."
<< endl;
return ERROR;
}
LYXERR(Debug::TCLASS, "Reading " + translateReadType(rt) + ": " +
to_utf8(makeDisplayPath(filename.absFileName())));
// Define the plain layout used in table cells, ert, etc. Note that
// we do this before loading any layout file, so that classes can
// override features of this layout if they should choose to do so.
if (rt == BASECLASS && !hasLayout(plain_layout_))
layoutlist_.push_back(createBasicLayout(plain_layout_));
Lexer lexrc(textClassTags);
lexrc.setFile(filename);
ReturnValues retval = read(lexrc, rt);
LYXERR(Debug::TCLASS, "Finished reading " + translateReadType(rt) + ": " +
to_utf8(makeDisplayPath(filename.absFileName())));
return retval;
}
示例2: getAsGraphics
FileName GuiClipboard::getAsGraphics(Cursor const & cur, GraphicsType type) const
{
// get the filename from the user
FileName filename = getPastedGraphicsFileName(cur, type);
if (filename.empty())
return FileName();
// handle image cases first
if (type == PngGraphicsType || type == JpegGraphicsType) {
// get image from QImage from clipboard
QImage image = qApp->clipboard()->image();
if (image.isNull()) {
LYXERR(Debug::ACTION, "No image in clipboard");
return FileName();
}
// convert into graphics format
QByteArray ar;
QBuffer buffer(&ar);
buffer.open(QIODevice::WriteOnly);
if (type == PngGraphicsType)
image.save(toqstr(filename.absFileName()), "PNG");
else if (type == JpegGraphicsType)
image.save(toqstr(filename.absFileName()), "JPEG");
else
LASSERT(false, /**/);
return filename;
}
示例3: registrer
bool LyXVC::registrer()
{
FileName const filename = owner_->fileName();
// there must be a file to save
if (!filename.isReadableFile()) {
Alert::error(_("Document not saved"),
_("You must save the document "
"before it can be registered."));
return false;
}
// it is very likely here that the vcs is not created yet...
if (!vcs) {
//check in the root directory of the document
FileName const cvs_entries(onlyPath(filename.absFileName()) + "/CVS/Entries");
FileName const svn_entries(onlyPath(filename.absFileName()) + "/.svn/entries");
FileName const git_index(onlyPath(filename.absFileName()) + "/.git/index");
if (git_index.isReadableFile()) {
LYXERR(Debug::LYXVC, "LyXVC: registering "
<< to_utf8(filename.displayName()) << " with GIT");
vcs.reset(new GIT(git_index, owner_));
} else if (svn_entries.isReadableFile()) {
LYXERR(Debug::LYXVC, "LyXVC: registering "
<< to_utf8(filename.displayName()) << " with SVN");
vcs.reset(new SVN(svn_entries, owner_));
} else if (cvs_entries.isReadableFile()) {
LYXERR(Debug::LYXVC, "LyXVC: registering "
<< to_utf8(filename.displayName()) << " with CVS");
vcs.reset(new CVS(cvs_entries, owner_));
} else {
LYXERR(Debug::LYXVC, "LyXVC: registering "
<< to_utf8(filename.displayName()) << " with RCS");
vcs.reset(new RCS(FileName(), owner_));
}
}
LYXERR(Debug::LYXVC, "LyXVC: registrer");
docstring response;
bool ok = Alert::askForText(response, _("LyX VC: Initial description"),
_("(no initial description)"));
if (!ok) {
LYXERR(Debug::LYXVC, "LyXVC: user cancelled");
vcs.reset(0);
return false;
}
if (response.empty())
response = _("(no initial description)");
vcs->registrer(to_utf8(response));
return true;
}
示例4: clonePermissions
bool FileName::clonePermissions(FileName const & source)
{
QFile fin(toqstr(source.absFileName()));
QFile f(toqstr(absFileName()));
return f.setPermissions(fin.permissions());
}
示例5: Converter
void CacheItem::Impl::convertToDisplayFormat()
{
LYXERR(Debug::GRAPHICS, "\tConverting it to " << to_ << " format.");
// Make a local copy in case we unzip it
FileName filename;
string from;
if (!tryDisplayFormat(filename, from)) {
// The image status has changed, tell it to the outside world.
statusChanged();
return;
}
// We will need a conversion, tell it to the outside world.
setStatus(Converting);
// Add some stuff to create a uniquely named temporary file.
// This file is deleted in loadImage after it is loaded into memory.
FileName const to_file_base = FileName::tempName("CacheItem");
remove_loaded_file_ = true;
// Connect a signal to this->imageConverted and pass this signal to
// the graphics converter so that we can load the modified file
// on completion of the conversion process.
converter_.reset(new Converter(filename, to_file_base.absFileName(), from, to_));
converter_->connect(bind(&Impl::imageConverted, this, _1));
converter_->startConversion();
}
示例6: file_not_found_hook
bool LyXVC::file_not_found_hook(FileName const & fn)
{
// Check if file is under RCS.
// This happens if we are trying to load non existent
// file on disk, but existent in ,v version.
bool foundRCS = !RCS::findFile(fn).empty();
bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
bool foundSVN = (foundRCS || foundCVS) ? false : !SVN::findFile(fn).empty();
bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : !GIT::findFile(fn).empty();
if (foundRCS || foundCVS || foundSVN || foundGIT) {
docstring const file = makeDisplayPath(fn.absFileName(), 20);
docstring const text =
bformat(_("Do you want to retrieve the document"
" %1$s from version control?"), file);
int const ret = Alert::prompt(_("Retrieve from version control?"),
text, 0, 1, _("&Retrieve"), _("&Cancel"));
if (ret == 0) {
// Since the retrieve commands are implemented using
// more general update commands we need to ensure that
// we do not change an existing file by accident.
if (fn.exists())
return false;
if (foundRCS)
return RCS::retrieve(fn);
else if (foundCVS)
return CVS::retrieve(fn);
else if (foundSVN)
return SVN::retrieve(fn);
else
return GIT::retrieve(fn);
}
}
return false;
}
示例7: findFile
FileName const RCS::findFile(FileName const & file)
{
// Check if *,v exists.
FileName tmp(file.absFileName() + ",v");
LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
if (tmp.isReadableFile()) {
LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
return tmp;
}
// Check if RCS/*,v exists.
tmp = FileName(addName(addPath(onlyPath(file.absFileName()), "RCS"), file.absFileName()) + ",v");
LYXERR(Debug::LYXVC, "LyXVC: Checking if file is under rcs: " << tmp);
if (tmp.isReadableFile()) {
LYXERR(Debug::LYXVC, "Yes, " << file << " is under rcs.");
return tmp;
}
return FileName();
}
示例8: copyFile
/** copy file \p sourceFile to \p destFile. If \p force is false, the user
* will be asked before existing files are overwritten. If \p only_tmp
* is true, then only copy files that are in our tmp dir (to avoid other files
* overwriting themselves).
* \return
* - SUCCESS if this file got copied
* - FORCE if subsequent calls should not ask for confirmation before
* overwriting files anymore.
* - CANCEL if the export should be cancelled
*/
CopyStatus copyFile(string const & format,
FileName const & sourceFile, FileName const & destFile,
string const & latexFile, bool force, bool only_tmp)
{
CopyStatus ret = force ? FORCE : SUCCESS;
// This check could be changed to
// boost::filesystem::equivalent(sourceFile, destFile) if export to
// other directories than the document directory is desired.
// Also don't overwrite files that already exist and are identical
// to the source files.
if ((only_tmp && !prefixIs(onlyPath(sourceFile.absFileName()), package().temp_dir().absFileName()))
|| sourceFile.checksum() == destFile.checksum())
return ret;
if (!force) {
switch(checkOverwrite(destFile)) {
case 0:
return SUCCESS;
case 1:
ret = SUCCESS;
break;
case 2:
ret = FORCE;
break;
default:
return CANCEL;
}
}
Mover const & mover = getMover(format);
if (!mover.copy(sourceFile, destFile, latexFile))
Alert::error(_("Couldn't copy file"),
bformat(_("Copying %1$s to %2$s failed."),
makeDisplayPath(sourceFile.absFileName()),
makeDisplayPath(destFile.absFileName())));
return ret;
}
示例9: checkOverwrite
/// Ask the user what to do if a file already exists
static int checkOverwrite(FileName const & filename)
{
if (!filename.exists())
return 1;
docstring text = bformat(_("The file %1$s already exists.\n\n"
"Do you want to overwrite that file?"),
makeDisplayPath(filename.absFileName()));
return Alert::prompt(_("Overwrite file?"),
text, 0, 3,
_("&Keep file"), _("&Overwrite"),
_("Overwrite &all"), _("&Cancel export"));
}
示例10: copy
bool ConverterCache::copy(FileName const & orig_from, string const & to_format,
FileName const & dest) const
{
if (!lyxrc.use_converter_cache || orig_from.empty() || dest.empty())
return false;
LYXERR(Debug::FILES, orig_from << ' ' << to_format << ' ' << dest);
// FIXME: Should not hardcode this (see bug 3819 for details)
if (to_format == "pstex") {
FileName const dest_eps(changeExtension(dest.absFileName(), "eps"));
if (!copy(orig_from, "eps", dest_eps))
return false;
} else if (to_format == "pdftex") {
FileName const dest_pdf(changeExtension(dest.absFileName(), "pdf"));
if (!copy(orig_from, "pdf", dest_pdf))
return false;
}
CacheItem * const item = pimpl_->find(orig_from, to_format);
LASSERT(item, /**/);
Mover const & mover = getMover(to_format);
return mover.copy(item->cache_name, dest,
onlyFileName(dest.absFileName()));
}
示例11: rescanTexStyles
void rescanTexStyles(string const & arg)
{
// Run rescan in user lyx directory
PathChanger p(package().user_support());
FileName const prog = support::libFileSearch("scripts", "TeXFiles.py");
Systemcall one;
string const command = os::python() + ' ' +
quoteName(prog.toFilesystemEncoding()) + ' ' +
arg;
int const status = one.startscript(Systemcall::Wait, command);
if (status == 0)
return;
// FIXME UNICODE
frontend::Alert::error(_("Could not update TeX information"),
bformat(_("The script `%1$s' failed."), from_utf8(prog.absFileName())));
}
示例12: getLogFile
string const LyXVC::getLogFile() const
{
if (!vcs)
return string();
TempFile tempfile("lyxvclog");
tempfile.setAutoRemove(false);
FileName const tmpf = tempfile.name();
if (tmpf.empty()) {
LYXERR(Debug::LYXVC, "Could not generate logfile " << tmpf);
return string();
}
LYXERR(Debug::LYXVC, "Generating logfile " << tmpf);
vcs->getLog(tmpf);
return tmpf.absFileName();
}
示例13: connect
/// Connect to the socket \p name.
int connect(FileName const & name)
{
int fd; // File descriptor for the socket
sockaddr_un addr; // Structure that hold the socket address
string const encoded = name.toFilesystemEncoding();
// char sun_path[108]
string::size_type len = encoded.size();
if (len > 107) {
cerr << "lyxclient: Socket address '" << name
<< "' too long." << endl;
return -1;
}
// Synonims for AF_UNIX are AF_LOCAL and AF_FILE
addr.sun_family = AF_UNIX;
encoded.copy(addr.sun_path, 107);
addr.sun_path[len] = '\0';
if ((fd = ::socket(PF_UNIX, SOCK_STREAM, 0))== -1) {
cerr << "lyxclient: Could not create socket descriptor: "
<< strerror(errno) << endl;
return -1;
}
if (::connect(fd,
reinterpret_cast<struct sockaddr *>(&addr),
sizeof(addr)) == -1) {
cerr << "lyxclient: Could not connect to socket " << name.absFileName()
<< ": " << strerror(errno) << endl;
::close(fd);
return -1;
}
if (::fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
cerr << "lyxclient: Could not set O_NONBLOCK for socket: "
<< strerror(errno) << endl;
::close(fd);
return -1;
}
return fd;
}
示例14: read
// Reads a textclass structure from file.
TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
{
if (!lexrc.isOK())
return ERROR;
// Format of files before the 'Format' tag was introduced
int format = 1;
bool error = false;
// parsing
while (lexrc.isOK() && !error) {
int le = lexrc.lex();
switch (le) {
case Lexer::LEX_FEOF:
continue;
case Lexer::LEX_UNDEF:
lexrc.printError("Unknown TextClass tag `$$Token'");
error = true;
continue;
default:
break;
}
// used below to track whether we are in an IfStyle or IfCounter tag.
bool ifstyle = false;
bool ifcounter = false;
switch (static_cast<TextClassTags>(le)) {
case TC_FORMAT:
if (lexrc.next())
format = lexrc.getInteger();
break;
case TC_OUTPUTFORMAT:
if (lexrc.next())
outputFormat_ = lexrc.getString();
break;
case TC_OUTPUTTYPE:
readOutputType(lexrc);
switch(outputType_) {
case LATEX:
outputFormat_ = "latex";
break;
case DOCBOOK:
outputFormat_ = "docbook";
break;
case LITERATE:
outputFormat_ = "literate";
break;
}
break;
case TC_INPUT: // Include file
if (lexrc.next()) {
string const inc = lexrc.getString();
FileName tmp = libFileSearch("layouts", inc,
"layout");
if (tmp.empty()) {
lexrc.printError("Could not find input file: " + inc);
error = true;
} else if (!read(tmp, MERGE)) {
lexrc.printError("Error reading input file: " + tmp.absFileName());
error = true;
}
}
break;
case TC_DEFAULTSTYLE:
if (lexrc.next()) {
docstring const name = from_utf8(subst(lexrc.getString(),
'_', ' '));
defaultlayout_ = name;
}
break;
case TC_IFSTYLE:
ifstyle = true;
// fall through
case TC_STYLE: {
if (!lexrc.next()) {
lexrc.printError("No name given for style: `$$Token'.");
error = true;
break;
}
docstring const name = from_utf8(subst(lexrc.getString(),
'_', ' '));
if (name.empty()) {
string s = "Could not read name for style: `$$Token' "
+ lexrc.getString() + " is probably not valid UTF-8!";
lexrc.printError(s);
Layout lay;
// Since we couldn't read the name, we just scan the rest
// of the style and discard it.
//.........这里部分代码省略.........
示例15: add
void ConverterCache::add(FileName const & orig_from, string const & to_format,
FileName const & converted_file) const
{
if (!lyxrc.use_converter_cache || orig_from.empty() ||
converted_file.empty())
return;
LYXERR(Debug::FILES, ' ' << orig_from
<< ' ' << to_format << ' ' << converted_file);
// FIXME: Should not hardcode this (see bug 3819 for details)
if (to_format == "pstex") {
FileName const converted_eps(changeExtension(converted_file.absFileName(), "eps"));
add(orig_from, "eps", converted_eps);
} else if (to_format == "pdftex") {
FileName const converted_pdf(changeExtension(converted_file.absFileName(), "pdf"));
add(orig_from, "pdf", converted_pdf);
}
// Is the file in the cache already?
CacheItem * item = pimpl_->find(orig_from, to_format);
time_t const timestamp = orig_from.lastModified();
Mover const & mover = getMover(to_format);
if (item) {
LYXERR(Debug::FILES, "ConverterCache::add(" << orig_from << "):\n"
"The file is already in the cache.");
// First test for timestamp
if (timestamp == item->timestamp) {
LYXERR(Debug::FILES, "Same timestamp.");
return;
}
// Maybe the contents is still the same?
item->timestamp = timestamp;
unsigned long const checksum = orig_from.checksum();
if (checksum == item->checksum) {
LYXERR(Debug::FILES, "Same checksum.");
return;
}
item->checksum = checksum;
if (!mover.copy(converted_file, item->cache_name,
onlyFileName(item->cache_name.absFileName()))) {
LYXERR(Debug::FILES, "Could not copy file " << orig_from << " to "
<< item->cache_name);
} else if (!item->cache_name.changePermission(0600)) {
LYXERR(Debug::FILES, "Could not change file mode"
<< item->cache_name);
}
} else {
CacheItem new_item(orig_from, to_format, timestamp,
orig_from.checksum());
if (mover.copy(converted_file, new_item.cache_name,
onlyFileName(new_item.cache_name.absFileName()))) {
if (!new_item.cache_name.changePermission(0600)) {
LYXERR(Debug::FILES, "Could not change file mode"
<< new_item.cache_name);
}
FormatCache & format_cache = pimpl_->cache[orig_from];
if (format_cache.from_format.empty())
format_cache.from_format =
formats.getFormatFromFile(orig_from);
format_cache.cache[to_format] = new_item;
} else
LYXERR(Debug::FILES, "ConverterCache::add(" << orig_from << "):\n"
"Could not copy file.");
}
}