#include <config.h>
#include "support/os.h"
-#include "debug.h"
+#include "support/docstring.h"
+#include "support/FileName.h"
+#include "support/lstrings.h"
+
+#include <limits.h>
+#include <stdlib.h>
#ifdef __APPLE__
#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H)
-#include "support/filetools.h"
-#include "support/Package.h"
-#include <fontconfig/fontconfig.h>
-using lyx::support::addPath;
#endif
-using std::endl;
-using std::string;
-
+using namespace std;
namespace lyx {
namespace support {
}
+bool isFilesystemCaseSensitive()
+{
+#ifdef __APPLE__
+ return false;
+#else
+ return true;
+#endif
+}
+
+
docstring::size_type common_path(docstring const & p1, docstring const & p2)
{
docstring::size_type i = 0;
}
-bool is_absolute_path(string const & p)
+bool is_valid_strftime(string const & p)
{
- return !p.empty() && p[0] == '/';
+ string::size_type pos = p.find_first_of('%');
+ while (pos != string::npos) {
+ if (pos + 1 == string::npos)
+ break;
+ if (!containsOnly(p.substr(pos + 1, 1),
+ "aAbBcCdDeEFgGhHIjklmMnOpPrRsStTuUVwWxXyYzZ%+"))
+ return false;
+ if (pos + 2 == string::npos)
+ break;
+ pos = p.find_first_of('%', pos + 2);
+ }
+ return true;
}
}
+bool is_terminal(io_channel channel)
+{
+ return isatty(channel);
+}
+
+
shell_type shell()
{
return UNIX;
}
-void addFontResources()
-{
-#ifdef __APPLE__
- CFBundleRef myAppBundle = CFBundleGetMainBundle();
- CFURLRef myAppResourcesURL, FontsURL;
- FSRef fontDirRef;
- FSSpec fontDirSpec;
- CFStringRef filePath = CFStringCreateWithBytes(kCFAllocatorDefault,
- (UInt8 *) "fonts", strlen("fonts"),
- kCFStringEncodingISOLatin1, false);
-
- myAppResourcesURL = CFBundleCopyResourcesDirectoryURL(myAppBundle);
- FontsURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,
- myAppResourcesURL, filePath, true);
- if (lyxerr.debugging(Debug::FONT)) {
- UInt8 buf[255];
- if (CFURLGetFileSystemRepresentation(FontsURL, true, buf, 255))
- lyxerr << "Adding Fonts directory: " << buf << endl;
- }
- CFURLGetFSRef (FontsURL, &fontDirRef);
- OSStatus err = FSGetCatalogInfo (&fontDirRef, kFSCatInfoNone,
- NULL, NULL, &fontDirSpec, NULL);
- if (err)
- lyxerr << "FSGetCatalogInfo err = " << err << endl;
- err = FMActivateFonts (&fontDirSpec, NULL, NULL,
- kFMLocalActivationContext);
- if (err)
- lyxerr << "FMActivateFonts err = " << err << endl;
-#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H)
- // Register BaKoMa truetype fonts with fontconfig
- string const fonts_dir =
- addPath(package().system_support().absFilename(), "fonts");
- if (!FcConfigAppFontAddDir(0, (FcChar8 const *)fonts_dir.c_str()))
- lyxerr << "Unable to register fonts with fontconfig." << endl;
-#endif
-}
-
-
-void restoreFontResources()
+string real_path(string const & path)
{
-#if defined(HAVE_FONTCONFIG_FONTCONFIG_H) && !defined(__APPLE__)
- FcConfigAppFontClear(0);
-#endif
+ char rpath[PATH_MAX + 1];
+ char * result = realpath(path.c_str(), rpath);
+ return FileName::fromFilesystemEncoding(result ? rpath : path).absFilename();
}
} // namespace os