From 12012124c9e9c1b60f8f5a65725fca990e4d4fb8 Mon Sep 17 00:00:00 2001 From: Hyunbin Lee Date: Tue, 19 Mar 2013 21:27:48 +0900 Subject: [PATCH] Support large file for getting file attributes. Change-Id: Id9711010487a3554408f8cb0fc118b31e95a74f4 Signed-off-by: Hyunbin Lee --- inc/FIoDirEntry.h | 4 ++-- inc/FIoFileAttributes.h | 5 +++-- src/io/CMakeLists.txt | 0 src/io/FIoDataRow.cpp | 0 src/io/FIoDataSet.cpp | 0 src/io/FIoDataSetEnumerator.cpp | 0 src/io/FIo_DataRowImpl.cpp | 0 src/io/FIo_DataSetEnumeratorImpl.cpp | 0 src/io/FIo_DataSetImpl.cpp | 0 src/io/FIo_DirEntryImpl.cpp | 4 ++-- src/io/FIo_DirEnumeratorImpl.cpp | 7 +++---- src/io/FIo_DirectoryImpl.cpp | 8 ++++---- src/io/FIo_FileAttributesImpl.cpp | 2 +- src/io/FIo_FileLockImpl.cpp | 9 +++++---- src/io/FIo_FileUtil.cpp | 21 ++++++++++----------- src/io/FIo_NormalFile.cpp | 13 +++++-------- src/io/inc/FIo_DataRowImpl.h | 0 src/io/inc/FIo_DataSetEnumeratorImpl.h | 0 src/io/inc/FIo_DataSetImpl.h | 0 src/io/inc/FIo_DirEntryImpl.h | 4 ++-- src/io/inc/FIo_FileAttributesImpl.h | 4 ++-- src/io/inc/FIo_IpcCommonParamTraits.h | 0 22 files changed, 39 insertions(+), 42 deletions(-) mode change 100755 => 100644 src/io/CMakeLists.txt mode change 100755 => 100644 src/io/FIoDataRow.cpp mode change 100755 => 100644 src/io/FIoDataSet.cpp mode change 100755 => 100644 src/io/FIoDataSetEnumerator.cpp mode change 100755 => 100644 src/io/FIo_DataRowImpl.cpp mode change 100755 => 100644 src/io/FIo_DataSetEnumeratorImpl.cpp mode change 100755 => 100644 src/io/FIo_DataSetImpl.cpp mode change 100755 => 100644 src/io/inc/FIo_DataRowImpl.h mode change 100755 => 100644 src/io/inc/FIo_DataSetEnumeratorImpl.h mode change 100755 => 100644 src/io/inc/FIo_DataSetImpl.h mode change 100755 => 100644 src/io/inc/FIo_IpcCommonParamTraits.h diff --git a/inc/FIoDirEntry.h b/inc/FIoDirEntry.h index 29d8d61..11d94fd 100644 --- a/inc/FIoDirEntry.h +++ b/inc/FIoDirEntry.h @@ -250,11 +250,11 @@ public: bool IsReadOnly(void) const; /** - * Gets the date and time of creation of the directory entry. + * Gets the date and time of last modification of the directory entry. * * @since 2.0 * - * @return The date and time of creation + * @return The date and time of last modification */ Tizen::Base::DateTime GetDateTime(void) const; diff --git a/inc/FIoFileAttributes.h b/inc/FIoFileAttributes.h index 8c5e345..a14ea97 100644 --- a/inc/FIoFileAttributes.h +++ b/inc/FIoFileAttributes.h @@ -218,11 +218,12 @@ public: bool IsReadOnly(void) const; /** - * Gets the date and time of the file creation. + * Gets the date and time of the file creation or last modification. * * @since 2.0 * - * @return The date and time of the file creation + * @return The date and time of the file creation or last modification + * @remarks If the created file is modified, its date and time is updated. */ Tizen::Base::DateTime GetDateTime(void) const; diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/src/io/FIoDataRow.cpp b/src/io/FIoDataRow.cpp old mode 100755 new mode 100644 diff --git a/src/io/FIoDataSet.cpp b/src/io/FIoDataSet.cpp old mode 100755 new mode 100644 diff --git a/src/io/FIoDataSetEnumerator.cpp b/src/io/FIoDataSetEnumerator.cpp old mode 100755 new mode 100644 diff --git a/src/io/FIo_DataRowImpl.cpp b/src/io/FIo_DataRowImpl.cpp old mode 100755 new mode 100644 diff --git a/src/io/FIo_DataSetEnumeratorImpl.cpp b/src/io/FIo_DataSetEnumeratorImpl.cpp old mode 100755 new mode 100644 diff --git a/src/io/FIo_DataSetImpl.cpp b/src/io/FIo_DataSetImpl.cpp old mode 100755 new mode 100644 diff --git a/src/io/FIo_DirEntryImpl.cpp b/src/io/FIo_DirEntryImpl.cpp index e60b8f2..bb8fb9f 100644 --- a/src/io/FIo_DirEntryImpl.cpp +++ b/src/io/FIo_DirEntryImpl.cpp @@ -142,7 +142,7 @@ unsigned long _DirEntryImpl::GetFileSize(void) const { SetLastResult(E_SUCCESS); - return __fileSize; + return static_cast< unsigned long >(__fileSize); } bool @@ -174,7 +174,7 @@ _DirEntryImpl::GetDateTime(void) const } void -_DirEntryImpl::Set(DateTime dateTime, unsigned long fileSize, String name, +_DirEntryImpl::Set(DateTime dateTime, off64_t fileSize, String name, bool dir, bool readOnly, bool hidden) { __dateTime = dateTime; diff --git a/src/io/FIo_DirEnumeratorImpl.cpp b/src/io/FIo_DirEnumeratorImpl.cpp index d3ddf28..0555258 100644 --- a/src/io/FIo_DirEnumeratorImpl.cpp +++ b/src/io/FIo_DirEnumeratorImpl.cpp @@ -118,7 +118,7 @@ _DirEnumeratorImpl::MoveNext(void) result r = E_SUCCESS; struct dirent dirEnt; struct dirent* pDirEntResult = null; - struct stat statbuf; + struct stat64 statbuf; struct tm* pTm = null; DateTime dateTime; int ret = 0; @@ -173,13 +173,12 @@ _DirEnumeratorImpl::MoveNext(void) "[%s] Invalid argument was passed. Given pattern length is not correct!", GetErrorMessage(GetLastResult())); // get its details - ret = stat(pAbsDirEntryPath.get(), &statbuf); + ret = stat64(pAbsDirEntryPath.get(), &statbuf); SysTryReturn(NID_IO, (ret == 0), r = __ConvertNativeErrorToResult(errno), __ConvertNativeErrorToResult(errno), "[%s] Failed to get attributes for dir entry (%s) whose absolute dirpath is (%s)with errno [%d].", __ConvertNativeErrorToMessage(errno), dirEnt.d_name, pAbsDirPath.get(), errno); - // time of last status change - pTm = localtime(&statbuf.st_ctime); + pTm = localtime(&statbuf.st_mtime); SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno)); r = dateTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec); SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r)); diff --git a/src/io/FIo_DirectoryImpl.cpp b/src/io/FIo_DirectoryImpl.cpp index 3f44ee4..813b06d 100644 --- a/src/io/FIo_DirectoryImpl.cpp +++ b/src/io/FIo_DirectoryImpl.cpp @@ -454,9 +454,9 @@ _DirectoryImpl::RemoveRecursively(char* pDirPath) strcat(absPath, dirEnt.d_name); //SysLog(NID_IO, "entry name: %s", absPath); - struct stat statbuf; - memset(&statbuf, 0, sizeof(struct stat)); - if (lstat(absPath, &statbuf) == -1) + struct stat64 statbuf; + memset(&statbuf, 0, sizeof(struct stat64)); + if (lstat64(absPath, &statbuf) == -1) { r = _NativeError::ConvertNativeErrorToResult(errno, true); SysLog(NID_IO, "[%s] Failed to get file status. errno: %d (%s)", @@ -465,7 +465,7 @@ _DirectoryImpl::RemoveRecursively(char* pDirPath) } if (!S_ISLNK(statbuf.st_mode)) { - if (stat(absPath, &statbuf) < 0) + if (stat64(absPath, &statbuf) < 0) { r = _NativeError::ConvertNativeErrorToResult(errno, true); SysLog(NID_IO, "[%s] Failed to get file status. errno: %d (%s)", diff --git a/src/io/FIo_FileAttributesImpl.cpp b/src/io/FIo_FileAttributesImpl.cpp index 61316e8..1b045b9 100644 --- a/src/io/FIo_FileAttributesImpl.cpp +++ b/src/io/FIo_FileAttributesImpl.cpp @@ -169,7 +169,7 @@ _FileAttributesImpl::IsReadOnly(void) const } void -_FileAttributesImpl::Set(const DateTime& dateTime, const DateTime& modifiedTime, long long fileSize, +_FileAttributesImpl::Set(const DateTime& dateTime, const DateTime& modifiedTime, off64_t fileSize, unsigned long attribute, bool hidden) { __fileSize = fileSize; diff --git a/src/io/FIo_FileLockImpl.cpp b/src/io/FIo_FileLockImpl.cpp index e2667f9..a61e8d9 100644 --- a/src/io/FIo_FileLockImpl.cpp +++ b/src/io/FIo_FileLockImpl.cpp @@ -55,8 +55,8 @@ _FileLockImpl::~_FileLockImpl(void) { __pFileImpl->__pFileLockImpl = null; int fd = fileno(__pFileImpl->GetFilePointer()); - struct stat statbuf; - SysTryReturnVoidResult(NID_IO, fstat(fd, &statbuf) == 0, E_SYSTEM, + struct stat64 statbuf; + SysTryReturnVoidResult(NID_IO, fstat64(fd, &statbuf) == 0, E_SYSTEM, "[E_SYSTEM] Failed to get file status. errno: %d (%s)", errno, strerror(errno)); // release the lock struct flock lock; @@ -119,8 +119,9 @@ _FileLockImpl::IsExclusive(void) const bool _FileLockImpl::IsValid(void) const { - struct stat statbuf; - SysTryReturn(NID_IO, __pFileImpl != null && (fstat(fileno(__pFileImpl->GetFilePointer()), &statbuf) == 0), false, E_SYSTEM, "[E_SYSTEM} File lock is invalid."); + struct stat64 statbuf; + SysTryReturn(NID_IO, __pFileImpl != null && (fstat64(fileno(__pFileImpl->GetFilePointer()), &statbuf) == 0), + false, E_SYSTEM, "[E_SYSTEM} File lock is invalid."); SetLastResult(E_SUCCESS); return true; } diff --git a/src/io/FIo_FileUtil.cpp b/src/io/FIo_FileUtil.cpp index 471dcd6..3276dd9 100644 --- a/src/io/FIo_FileUtil.cpp +++ b/src/io/FIo_FileUtil.cpp @@ -163,7 +163,7 @@ result _FileUtil::Move(const String& oldFilePath, const String& newFilePath) { result r = E_SUCCESS; - struct stat statBuf; + struct stat64 statBuf; unique_ptr pOldPath(_StringConverter::CopyToCharArrayN(oldFilePath)); SysTryReturn(NID_IO, pOldPath != null, GetLastResult(), GetLastResult(), @@ -179,10 +179,11 @@ _FileUtil::Move(const String& oldFilePath, const String& newFilePath) SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(oldFilePath) == true, E_FILE_NOT_FOUND, "Old filepath not found."); - if (stat(pOldPath.get(), &statBuf) < 0) + if (stat64(pOldPath.get(), &statBuf) < 0) { r = __ConvertNativeErrorToResult(errno); - SysLogException(NID_IO, r, "[%s] stat() failed, path: %s, errno: %d (%s)", GetErrorMessage(r), pOldPath.get(), errno, strerror(errno)); + SysLogException(NID_IO, r, "[%s] stat64() failed, path: %s, errno: %d (%s)", + GetErrorMessage(r), pOldPath.get(), errno, strerror(errno)); return r; } SysTryReturnResult(NID_IO, S_ISDIR(statBuf.st_mode) == false, E_INVALID_ARG, @@ -236,14 +237,14 @@ _FileUtil::Copy(const String& srcFilePath, const String& destFilePath, bool fail return r; } - srcFd = open(pSrcpath.get(), O_RDONLY); + srcFd = open64(pSrcpath.get(), O_RDONLY); if (srcFd == -1) { r = __ConvertNativeErrorToResult(errno); SysLogException(NID_IO, r, "[%s] Failed to open file (%s).", GetErrorMessage(r), pSrcpath.get()); return r; } - dstFd = open(pDstpath.get(), O_WRONLY | O_CREAT | O_TRUNC, 0644); + dstFd = open64(pDstpath.get(), O_WRONLY | O_CREAT | O_TRUNC, 0644); if (dstFd == -1) { r = __ConvertNativeErrorToResult(errno); @@ -317,7 +318,7 @@ _FileUtil::GetAttributes(const String& filePath, FileAttributes& attribute) { DateTime dateTime; DateTime modifiedTime; - long long fileSize = 0; + off64_t fileSize = 0; unsigned long attr = 0; result r = E_SUCCESS; struct tm* pTm = null; @@ -328,8 +329,8 @@ _FileUtil::GetAttributes(const String& filePath, FileAttributes& attribute) SysTryReturn(NID_IO, (pFilePath != null), GetLastResult(), GetLastResult(), "[%s] Invalid source file path.", GetErrorMessage(GetLastResult())); - struct stat statbuf; - if (int ret = stat(pFilePath.get(), &statbuf) == -1) + struct stat64 statbuf; + if (int ret = stat64(pFilePath.get(), &statbuf) == -1) { r = __ConvertNativeErrorToResult(errno); SysLogException(NID_IO, r, "[%s] Failed to get file (%s) status.", GetErrorMessage(r), pFilePath.get()); @@ -342,13 +343,11 @@ _FileUtil::GetAttributes(const String& filePath, FileAttributes& attribute) // attributes attr = statbuf.st_mode; - // time of last status change - pTm = localtime(&statbuf.st_ctime); + pTm = localtime(&statbuf.st_mtime); SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno)); r = dateTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec); SysTryReturn(NID_IO, (!IsFailed(r)), r, r, "[%s] Failed to set DateTime.", GetErrorMessage(r)); - // time of last modification pTm = localtime(&statbuf.st_mtime); SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno)); r = modifiedTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec); diff --git a/src/io/FIo_NormalFile.cpp b/src/io/FIo_NormalFile.cpp index 5216c64..3141ee6 100644 --- a/src/io/FIo_NormalFile.cpp +++ b/src/io/FIo_NormalFile.cpp @@ -106,18 +106,15 @@ result _NormalFile::ReadN(char** buffer, int& length) { SysAssertf(__pFile != NULL, "Not yet constructed. Construct() should be called before use.\n"); - result r = E_SUCCESS; - int fileSize = 0; - int ret = 0; - ret = fseek(__pFile, 0, SEEK_END); + int ret = fseek(__pFile, 0, SEEK_END); SysTryReturnResult(NID_IO, ret >= 0, E_SYSTEM, "The system I/O error occurred."); - fileSize = ftell(__pFile); + long fileSize = ftell(__pFile); SysTryReturnResult(NID_IO, fileSize >= 0, E_SYSTEM, "The system I/O error occurred."); - SysLog(NID_IO, "The length of registry file (%ls) is %d.", __filePath.GetPointer(), fileSize); + SysLog(NID_IO, "The length of registry file (%ls) is %ld.", __filePath.GetPointer(), fileSize); if (fileSize == 0) { return E_SUCCESS; @@ -130,7 +127,7 @@ _NormalFile::ReadN(char** buffer, int& length) SysTryReturnResult(NID_IO, pBuffer != null, E_OUT_OF_MEMORY, "The memory is insufficient."); memset(pBuffer.get(), 0x00, fileSize + 1); - int readBytes = fread((void*)pBuffer.get(), 1, fileSize, __pFile); + int readBytes = fread((void*)pBuffer.get(), 1, (size_t)fileSize, __pFile); SysTryCatch(NID_IO, readBytes > 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to read registry file (%d, %s).", errno, strerror(errno)); @@ -389,7 +386,7 @@ _NormalFile::Truncate(int length) SysAssertf(__pFile != NULL, "Not yet constructed. Construct() should be called before use.\n"); result r = E_SUCCESS; - int ret = ftruncate(fileno(__pFile), (off_t) length); + int ret = ftruncate(fileno(__pFile), (off_t)length); if (ret != 0) { r = __ConvertNativeErrorToResult(errno); diff --git a/src/io/inc/FIo_DataRowImpl.h b/src/io/inc/FIo_DataRowImpl.h old mode 100755 new mode 100644 diff --git a/src/io/inc/FIo_DataSetEnumeratorImpl.h b/src/io/inc/FIo_DataSetEnumeratorImpl.h old mode 100755 new mode 100644 diff --git a/src/io/inc/FIo_DataSetImpl.h b/src/io/inc/FIo_DataSetImpl.h old mode 100755 new mode 100644 diff --git a/src/io/inc/FIo_DirEntryImpl.h b/src/io/inc/FIo_DirEntryImpl.h index 059bf88..8e0398b 100644 --- a/src/io/inc/FIo_DirEntryImpl.h +++ b/src/io/inc/FIo_DirEntryImpl.h @@ -75,11 +75,11 @@ public: private: _DirEntryImpl(void); - void Set(Tizen::Base::DateTime dateTime, unsigned long fileSize, + void Set(Tizen::Base::DateTime dateTime, off64_t fileSize, Tizen::Base::String name, bool dir, bool readOnly, bool hidden); Tizen::Base::DateTime __dateTime; - unsigned long __fileSize; + off64_t __fileSize; Tizen::Base::String __name; bool __directory; bool __hidden; diff --git a/src/io/inc/FIo_FileAttributesImpl.h b/src/io/inc/FIo_FileAttributesImpl.h index e1f386e..cea63a1 100644 --- a/src/io/inc/FIo_FileAttributesImpl.h +++ b/src/io/inc/FIo_FileAttributesImpl.h @@ -70,11 +70,11 @@ public: Tizen::Base::DateTime GetLastModifiedTime(void) const; private: - void Set(const Tizen::Base::DateTime& dateTime, const Tizen::Base::DateTime& modifiedTime, long long fileSize, + void Set(const Tizen::Base::DateTime& dateTime, const Tizen::Base::DateTime& modifiedTime, off64_t fileSize, unsigned long attribute, bool hidden); private: - long long __fileSize; + off64_t __fileSize; bool __directory; bool __hidden; bool __readOnly; diff --git a/src/io/inc/FIo_IpcCommonParamTraits.h b/src/io/inc/FIo_IpcCommonParamTraits.h old mode 100755 new mode 100644 -- 2.7.4