]> git.lyx.org Git - features.git/commitdiff
* src/support/os.h
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 18 May 2006 19:09:53 +0000 (19:09 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 18 May 2006 19:09:53 +0000 (19:09 +0000)
(canAutoOpenFile): correct comment
(autoOpenFile): ditto

* src/support/os_win32.C
(canAutoOpenFile): Remove unneeded test for dot
(autoOpenFile): whitespace

* src/support/os_cygwin.C
(canAutoOpenFile): Remove unneeded test for dot
(autoOpenFile): whitespace

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13866 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/os.h
src/support/os_cygwin.C
src/support/os_win32.C

index 415868f8029f7798996902cd0bc17dd319f36813..3b23b0ee2272f725af75edac5d8347c74ecd0fa1 100644 (file)
@@ -85,19 +85,19 @@ enum auto_open_mode {
        EDIT
 };
 
-/** Check whether or not a file can be viewed by a default viewer 
+/** Check whether or not a file can be opened by a default viewer or editor.
  *  \param extension (without leading .)
- *  \mode can be opened in VIEW or EDIT mode
- *  \returns whether or not the format can be viewed
+ *  \param mode can be opened in VIEW or EDIT mode
+ *  \returns whether or not the format can be opened according to \p mode
  */
-bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode=VIEW);
+bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
 
-/** view a file, with given command and parameter.
- *  \param filename
+/** View or edit a file with the default viewer or editor.
+ *  \param filename file to open
  *  \param mode open in VIEW or EDIT mode
  *  \returns whether or not the file is viewed (or edited) successfully.
  */
-bool autoOpenFile(std::string const & filename, auto_open_mode const mode=VIEW);
+bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
 
 } // namespace os
 } // namespace support
index 094b50788a450ffb62826a43aa5efeb683621a8a..3a58f00198b6d613beffed5e334e7cb906551316 100644 (file)
@@ -278,11 +278,8 @@ bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
 {
        if (ext.empty())
                return false;
-       
-       string full_ext = ext;
-       // if the extension is passed without leading dot
-       if (full_ext[0] != '.')
-               full_ext = "." + ext;
+
+       string const full_ext = "." + ext;
 
        DWORD bufSize = MAX_PATH + 100;
        TCHAR buf[MAX_PATH + 100];
@@ -301,7 +298,7 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
        string const win_path =
                os::convert_path(filename, os::PathStyle(os::windows));
        char const * action = (mode == VIEW) ? "open" : "edit";
-       return reinterpret_cast<int>(ShellExecute(NULL, action, 
+       return reinterpret_cast<int>(ShellExecute(NULL, action,
                win_path.c_str(), NULL, NULL, 1)) > 32;
 }
 
index 4467fa68760a5f2b3838c1c3cfa3049be559696b..1b5d094dc1ca9ded241968d1938da9b6d7c0d157 100644 (file)
@@ -397,11 +397,8 @@ bool canAutoOpenFile(string const & ext, auto_open_mode const mode)
 {
        if (ext.empty())
                return false;
-       
-       string full_ext = ext;
-       // if the extension is passed without leading dot
-       if (full_ext[0] != '.')
-               full_ext = "." + ext;
+
+       string const full_ext = "." + ext;
 
        DWORD bufSize = MAX_PATH + 100;
        TCHAR buf[MAX_PATH + 100];
@@ -418,7 +415,7 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
        // reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc
        //                 /platform/shell/reference/functions/shellexecute.asp
        char const * action = (mode == VIEW) ? "open" : "edit";
-       return reinterpret_cast<int>(ShellExecute(NULL, action, 
+       return reinterpret_cast<int>(ShellExecute(NULL, action,
                filename.c_str(), NULL, NULL, 1)) > 32;
 }