using namespace std;
using namespace lyx::support;
-// OK, this is ugly, but it is the only workaround I found to compile
-// with gcc (any version) on a system which uses a non-GNU toolchain.
-// The problem is that gcc uses a weak symbol for a particular
-// instantiation and that the system linker usually does not
-// understand those weak symbols (seen on HP-UX, tru64, AIX and
-// others). Thus we force an explicit instanciation of this particular
-// template (JMarc)
-template struct boost::detail::crc_table_t<32, 0x04C11DB7, true>;
-
namespace lyx {
namespace support {
static
string const handleTildeName(string const & name)
{
- return name == "~" ? Package::get_home_dir().absFileName() :
- prefixIs(name, "~/") ? Package::get_home_dir().absFileName() + name.substr(1) :
- name;
+ string resname;
+ if ( name == "~" )
+ resname = Package::get_home_dir().absFileName();
+ else if ( prefixIs(name, "~/"))
+ resname = Package::get_home_dir().absFileName() + name.substr(1);
+ else if ( prefixIs(name, "~:s/"))
+ resname = package().system_support().absFileName() + name.substr(3);
+ else
+ resname = name;
+ return resname;
}
/// The absolute file name in UTF-8 encoding.
<< mode << ".");
return false;
}
+#else
+ // squash warning
+ (void) mode;
#endif
return true;
}
+bool FileName::clonePermissions(FileName const & source)
+{
+ QFile fin(toqstr(source.absFileName()));
+ QFile f(toqstr(absFileName()));
+
+ return f.setPermissions(fin.permissions());
+}
string FileName::toFilesystemEncoding() const
{
// Only used in non Win32 platforms
+#ifndef Q_OS_WIN32
static int mymkdir(char const * pathname, unsigned long int mode)
{
// FIXME: why don't we have mode_t in lyx::mkdir prototype ??
-#if HAVE_MKDIR
-# if MKDIR_TAKES_ONE_ARG
+# if HAVE_MKDIR
+# if MKDIR_TAKES_ONE_ARG
// MinGW32
return ::mkdir(pathname);
// FIXME: "Permissions of created directories are ignored on this system."
-# else
+# else
// POSIX
return ::mkdir(pathname, mode_t(mode));
-# endif
-#elif defined(_WIN32)
+# endif
+# elif defined(_WIN32)
// plain Windows 32
return CreateDirectory(pathname, 0) != 0 ? 0 : -1;
// FIXME: "Permissions of created directories are ignored on this system."
-#elif HAVE__MKDIR
+# elif HAVE__MKDIR
return ::_mkdir(pathname);
// FIXME: "Permissions of created directories are ignored on this system."
-#else
+# else
# error "Don't know how to create a directory on this system."
-#endif
-
+# endif
}
+#endif
bool FileName::createDirectory(int permission) const
LASSERT(!empty(), return false);
#ifdef Q_OS_WIN32
// FIXME: "Permissions of created directories are ignored on this system."
+ (void) permission;
return createPath();
#else
return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;