[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sal/inc
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 21 03:57:02 PDT 2012
sal/inc/osl/file.hxx | 67 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 47 insertions(+), 20 deletions(-)
New commits:
commit fa4fec47a8bb713f960acb474920f2c640e1c58a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Aug 21 12:27:12 2012 +0200
Related fdo#46249: FileStatus can have fewer fields than requested
Turns out 608fe962cc649ad62c489811d3a8666e0e06e5e7 "Let osl::FileStatus getters
assert programming errors" was overly optimistic and misunderstood that
osl_getFileStatus(..., nMask) /can/ return a FileStatus for which isValid(nMask)
is false, esp. for stuff like file names and URLs of Windows drives and servers.
That in turn leads to existing code now calling
rtl::OUString(_aStatus.ustrFileName) etc. with null argument and crashing.
Change-Id: Icd2168e209aa1c7a6df30cd954513d01034923db
Signed-off-by: Michael Meeks <michael.meeks at suse.com>
diff --git a/sal/inc/osl/file.hxx b/sal/inc/osl/file.hxx
index 16f7a06..96a7cda 100644
--- a/sal/inc/osl/file.hxx
+++ b/sal/inc/osl/file.hxx
@@ -729,8 +729,11 @@ public:
*/
inline Type getFileType() const
{
- assert(isValid(osl_FileStatus_Mask_Type));
- return static_cast< Type >(_aStatus.eType);
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_Type), "sal",
+ "no FileStatus Type determined");
+ return isValid(osl_FileStatus_Mask_Type)
+ ? static_cast< Type >(_aStatus.eType) : Unknown;
}
/** Is it a directory?
@@ -783,93 +786,117 @@ public:
inline sal_uInt64 getAttributes() const
{
- assert(isValid(osl_FileStatus_Mask_Attributes));
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_Attributes), "sal",
+ "no FileStatus Attributes determined");
return _aStatus.uAttributes;
}
/** Get the creation time of this file.
@return
- The creation time.
+ The creation time if this information is valid, an uninitialized
+ TimeValue otherwise.
*/
inline TimeValue getCreationTime() const
{
- assert(isValid(osl_FileStatus_Mask_CreationTime));
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_CreationTime), "sal",
+ "no FileStatus CreationTime determined");
return _aStatus.aCreationTime;
}
/** Get the file access time.
@return
- The last access time.
+ The last access time if this information is valid, an uninitialized
+ TimeValue otherwise.
*/
inline TimeValue getAccessTime() const
{
- assert(isValid(osl_FileStatus_Mask_AccessTime));
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_AccessTime), "sal",
+ "no FileStatus AccessTime determined");
return _aStatus.aAccessTime;
}
/** Get the file modification time.
@return
- The last modified time.
+ The last modified time if this information is valid, an uninitialized
+ TimeValue otherwise.
*/
inline TimeValue getModifyTime() const
{
- assert(isValid(osl_FileStatus_Mask_ModifyTime));
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_ModifyTime), "sal",
+ "no FileStatus ModifyTime determined");
return _aStatus.aModifyTime;
}
/** Get the size of the file.
@return
- The actual file size.
+ The actual file size if this information is valid, 0 otherwise.
*/
inline sal_uInt64 getFileSize() const
{
- assert(isValid(osl_FileStatus_Mask_FileSize));
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_FileSize), "sal",
+ "no FileStatus FileSize determined");
return _aStatus.uFileSize;
}
/** Get the file name.
@return
- The file name.
+ The file name if this information is valid, an empty string otherwise.
*/
inline ::rtl::OUString getFileName() const
{
- assert(isValid(osl_FileStatus_Mask_FileName));
- return rtl::OUString(_aStatus.ustrFileName);
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_FileName), "sal",
+ "no FileStatus FileName determined");
+ return isValid(osl_FileStatus_Mask_FileName)
+ ? rtl::OUString(_aStatus.ustrFileName) : rtl::OUString();
}
/** Get the URL of the file.
@return
- The full qualified URL of the file.
+ The full qualified URL of the file if this information is valid, an
+ empty string otherwise.
*/
inline ::rtl::OUString getFileURL() const
{
- assert(isValid(osl_FileStatus_Mask_FileURL));
- return rtl::OUString(_aStatus.ustrFileURL);
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_FileURL), "sal",
+ "no FileStatus FileURL determined");
+ return isValid(osl_FileStatus_Mask_FileURL)
+ ? rtl::OUString(_aStatus.ustrFileURL) : rtl::OUString();
}
/** Get the link target URL.
@return
- The link target URL.
+ The link target URL if this information is valid, an empty string
+ otherwise.
*/
inline ::rtl::OUString getLinkTargetURL() const
{
- assert(isValid(osl_FileStatus_Mask_LinkTargetURL));
- return rtl::OUString(_aStatus.ustrLinkTargetURL);
+ SAL_INFO_IF(
+ !isValid(osl_FileStatus_Mask_LinkTargetURL), "sal",
+ "no FileStatus LinkTargetURL determined");
+ return isValid(osl_FileStatus_Mask_LinkTargetURL)
+ ? rtl::OUString(_aStatus.ustrLinkTargetURL) : rtl::OUString();
}
friend class DirectoryItem;
More information about the Libreoffice-commits
mailing list