3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Ruurd A. Reitsma
8 * Full author contact details are available in file CREDITS.
10 * Various OS specific functions
15 #include "support/os.h"
16 #include "support/docstring.h"
17 #include "support/FileName.h"
20 #include <Carbon/Carbon.h>
29 void init(int, char *[])
39 bool isFilesystemCaseSensitive()
49 docstring::size_type common_path(docstring const & p1, docstring const & p2)
51 docstring::size_type i = 0;
52 docstring::size_type const p1_len = p1.length();
53 docstring::size_type const p2_len = p2.length();
54 while (i < p1_len && i < p2_len && p1[i] == p2[i])
56 if ((i < p1_len && i < p2_len)
57 || (i < p1_len && p1[i] != '/' && i == p2_len)
58 || (i < p2_len && p2[i] != '/' && i == p1_len))
61 --i; // here was the last match
62 while (i && p1[i] != '/')
69 string external_path(string const & p)
75 string internal_path(string const & p)
81 string external_path_list(string const & p)
87 string internal_path_list(string const & p)
93 string latex_path(string const & p)
99 char const * popen_read_mode()
105 string const & nulldev()
107 static string const nulldev_ = "/dev/null";
118 char path_separator()
124 void windows_style_tex_paths(bool)
127 bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
130 // Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
131 CFStringRef cfs_ext = CFStringCreateWithBytes(kCFAllocatorDefault,
132 (UInt8 *) ext.c_str(), ext.length(),
133 kCFStringEncodingISOLatin1, false);
134 // this is what we would like to do but it seems that the
135 // viewer for PDF is often quicktime...
136 //LSRolesMask role = (mode == VIEW) ? kLSRolesViewer : kLSRolesEditor;
138 LSRolesMask role = kLSRolesAll;
141 LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator,
142 cfs_ext, role, &outAppRef, NULL);
145 return status != kLSApplicationNotFoundErr;
147 // silence compiler warnings
151 // currently, no default viewer is tried for non-windows system
152 // support for KDE/Gnome/Macintosh may be added later
158 bool autoOpenFile(string const & filename, auto_open_mode const mode)
161 // Reference: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/
164 FSPathMakeRef((UInt8 *) filename.c_str(), &fileref, NULL);
168 // this is what we would like to do but it seems that the
169 // viewer for PDF is often quicktime...
170 //LSRolesMask role = (mode == VIEW) ? kLSRolesViewer : kLSRolesEditor;
172 LSRolesMask role = kLSRolesAll;
175 status = LSGetApplicationForItem(&fileref, role, &outAppRef, NULL);
176 if (status == kLSApplicationNotFoundErr)
179 LSLaunchFSRefSpec inLaunchSpec;
180 inLaunchSpec.appRef = &outAppRef;
181 inLaunchSpec.numDocs = 1;
182 inLaunchSpec.itemRefs = &fileref;
183 inLaunchSpec.passThruParams = NULL;
184 inLaunchSpec.launchFlags = kLSLaunchDefaults;
185 inLaunchSpec.asyncRefCon = NULL;
186 status = LSOpenFromRefSpec(&inLaunchSpec, NULL);
188 return status != kLSApplicationNotFoundErr;
190 // silence compiler warnings
194 // currently, no default viewer is tried for non-windows system
195 // support for KDE/Gnome/Macintosh may be added later
201 } // namespace support