Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Just looking at the below function itself (so no idea about the larger context), I noted a few things:

On 03/19/2012 01:17 AM, Andrzej J. R. Hunt wrote:
+void FileDialogHelper_Impl::verifyPath()
+{
+    struct stat aFileStat;
+    const char* pFullPath = OUStringToOString( ( maPath.copy(7) + maFileName ),

copy(7) could be replaced with copy(RTL_CONSTASCII_LENGTH("file://")) to make it more obvious what's going on.

+            osl_getThreadTextEncoding() ).getStr();

pFullPath points to delete memory now, as the OString temporary goes out of scope at the end of the statement.

+    stat( pFullPath,&aFileStat );

See osl/file.hxx for LO's cross-platform stat abstraction facilities -- if they are not expressive enough for the problem at hand, this code would need to be properly ifdef'ed for POSIX (explicitly checking for /tmp indicates this is only a Unix-style problem and/or solution, anyway).

+    // Check that the file has read only permission and is in /tmp -- this is
+    //  the case if we have opened the file from the web with firefox only.
+    if ( maPath.compareTo("file:///tmp",11) == 0&&
+            ( aFileStat.st_mode&  (S_IRWXO + S_IRWXG + S_IRWXU) ) == S_IRUSR ) {
+        maPath = SvtPathOptions().GetWorkPath();
+        mxFileDlg->setDisplayDirectory( maPath );
+    }
+}

Sorry that this is just non-constructive drive-by comments for now...

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.