diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-03-09 11:52:09 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-03-09 11:56:10 +0100 |
commit | 608fe962cc649ad62c489811d3a8666e0e06e5e7 (patch) | |
tree | d9bcc379775a68647fa850a2e613be97650d17dd /sal | |
parent | f3f6c9be9864088b94f874c6ef2ce8ab1dd45f2a (diff) |
Let osl::FileStatus getters assert programming errors
...instead of arbitrarily returning certain values when the requested
information is not available.
This reveals a problem in strmunx.cxx that is apparently a regression introduced
with 4a086fca7b0a77c20bc9f1c97507966e2861f3da "fix SvStream to not require a
custom open or lstat method."
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/osl/file.hxx | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx index ee3ac1fc29d3..2cc43d03531d 100644 --- a/sal/inc/osl/file.hxx +++ b/sal/inc/osl/file.hxx @@ -29,14 +29,16 @@ #ifndef _OSL_FILE_HXX_ #define _OSL_FILE_HXX_ -#ifdef __cplusplus +#include "sal/config.h" + +#include <cassert> #include <osl/time.h> -# include <rtl/memory.h> -# include <rtl/ustring.hxx> +#include <rtl/memory.h> +#include <rtl/ustring.hxx> #include <osl/file.h> -# include <rtl/byteseq.hxx> +#include <rtl/byteseq.hxx> #include <stdio.h> @@ -723,11 +725,12 @@ public: /** Get the file type. @return - The file type if this information is valid, Unknown otherwise. + The file type. */ inline Type getFileType() const { - return (_aStatus.uValidFields & osl_FileStatus_Mask_Type) ? (Type) _aStatus.eType : Unknown; + assert(isValid(osl_FileStatus_Mask_Type)); + return static_cast< Type >(_aStatus.eType); } /** Is it a file? @@ -796,88 +799,93 @@ public: inline sal_uInt64 getAttributes() const { + assert(isValid(osl_FileStatus_Mask_Attributes)); return _aStatus.uAttributes; } /** Get the creation time of this file. @return - The creation time if this information is valid, - an uninitialized TimeValue otherwise. + The creation time. */ inline TimeValue getCreationTime() const { + assert(isValid(osl_FileStatus_Mask_CreationTime)); return _aStatus.aCreationTime; } /** Get the file access time. @return - The last access time if this information is valid, - an uninitialized TimeValue otherwise. + The last access time. */ inline TimeValue getAccessTime() const { + assert(isValid(osl_FileStatus_Mask_AccessTime)); return _aStatus.aAccessTime; } /** Get the file modification time. @return - The last modified time if this information is valid, - an uninitialized TimeValue otherwise. + The last modified time. */ inline TimeValue getModifyTime() const { + assert(isValid(osl_FileStatus_Mask_ModifyTime)); return _aStatus.aModifyTime; } /** Get the size of the file. @return - The actual file size if this information is valid, 0 otherwise. + The actual file size. */ inline sal_uInt64 getFileSize() const { + assert(isValid(osl_FileStatus_Mask_FileSize)); return _aStatus.uFileSize; } /** Get the file name. @return - The file name if this information is valid, an empty string otherwise. + The file name. */ inline ::rtl::OUString getFileName() const { - return _aStatus.ustrFileName ? ::rtl::OUString(_aStatus.ustrFileName) : ::rtl::OUString(); + assert(isValid(osl_FileStatus_Mask_FileName)); + return rtl::OUString(_aStatus.ustrFileName); } /** Get the URL of the file. @return - The full qualified URL of the file if this information is valid, an empty string otherwise. + The full qualified URL of the file. */ inline ::rtl::OUString getFileURL() const { - return _aStatus.ustrFileURL ? ::rtl::OUString(_aStatus.ustrFileURL) : ::rtl::OUString(); + assert(isValid(osl_FileStatus_Mask_FileURL)); + return rtl::OUString(_aStatus.ustrFileURL); } /** Get the link target URL. @return - The link target URL if this information is valid, an empty string otherwise. + The link target URL. */ inline ::rtl::OUString getLinkTargetURL() const { - return _aStatus.ustrLinkTargetURL ? ::rtl::OUString(_aStatus.ustrLinkTargetURL) : ::rtl::OUString(); + assert(isValid(osl_FileStatus_Mask_LinkTargetURL)); + return rtl::OUString(_aStatus.ustrLinkTargetURL); } friend class DirectoryItem; @@ -1947,7 +1955,6 @@ public: } /* namespace osl */ -#endif /* __cplusplus */ #endif /* _OSL_FILE_HXX_ */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |