https://bugs.freedesktop.org/show_bug.cgi?id=44982

             Bug #: 44982
           Summary: EasyHack: add helper method to sal's File abstraction
    Classification: Unclassified
           Product: LibreOffice
           Version: LibO Master
          Platform: Other
        OS/Version: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Libreoffice
        AssignedTo: [email protected]
        ReportedBy: [email protected]


The sal/ file abstraction is great, but has some slightly cumbersome uses that
could be easily fixed with some more inline methods:

sal/inc/osl/file.hxx

We have an osl::FileStatus class. A major use of this is detecting if a file is
a File or a Directory (or a Link).

    if( aStatus.getFileType() == osl::FileStatus::Directory )
    bool bDirectory = fs.getFileType() == osl::FileStatus::Directory;
    if ( aFileStatus.getFileType() == osl::FileStatus::Link )

etc. basic/source/runtime/methods.cxx even has a:

static inline sal_Bool isFolder( FileStatus::Type aType )
{
    return ( aType == FileStatus::Directory || aType == FileStatus::Volume );
}

Which looks like a common programming error is hidden by this 'directory could
be a folder and a mount point but then has type 'volume'.

To help this it'd be great to have some inline methods:

isFile()
isFolder()
isLink()

that essentially check the getFileType() value as appropriate, and then to do
the cleanup across the code to use these.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to