2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FIo_FileUtil.cpp
19 * @brief This is the implementation file for _FileUtil class.
26 #include <sys/types.h>
33 #include <unique_ptr.h>
36 #include <FIoDirectory.h>
37 #include <FBaseResult.h>
38 #include <FBaseSysLog.h>
39 #include <FLclLocaleManager.h>
40 #include <FLclTimeZone.h>
42 #include <FBase_StringConverter.h>
43 #include <FBase_NativeError.h>
44 #include <FApp_AppInfo.h>
45 #include <FIo_FileAttributesImpl.h>
46 #include <FIo_SecureIoUtil.h>
47 #include <FIo_FileImpl.h>
48 #include <FIo_FileUtil.h>
51 using namespace Tizen::Base;
52 using namespace Tizen::Locales;
53 using namespace Tizen::App;
55 namespace Tizen { namespace Io
58 static const int _BASE_YEAR = 1900;
59 static const int _MAX_COPY_BYTES = 4096;
61 //Holds app path prefixes
62 static const char* filePathAppPrefix[] =
76 "/Storagecard/DownloadedAppPackages",
84 //Holds Media path prefixes
85 static const char* filePathMediaPrefix[] =
91 //Holds system path prefixes
92 static const char* filePathSystemPrefix[] =
94 "/system/configuration",
99 _FileUtil::Remove(const String& filePath)
101 result r = E_SUCCESS;
102 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
103 SysTryReturn(NID_IO, (pFilePath != null), GetLastResult(), GetLastResult(), ("[%s] Invalid file path."),
104 GetErrorMessage(GetLastResult()));
106 if (_FileUtil::IsFileExist(pFilePath.get()) == false)
108 SysSecureLogException(NID_IO, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] File (%s) does not exist.", pFilePath.get());
109 return E_FILE_NOT_FOUND;
112 char resolvedPath[PATH_MAX] = {0,};
113 if (realpath(pFilePath.get(), resolvedPath) == null)
118 r = E_ILLEGAL_ACCESS;
133 r = E_FILE_NOT_FOUND;
140 SysLog(NID_IO, "[%s] Failed to produce canonical absolute path (%ls). errno: %d (%s)",
141 GetErrorMessage(r), filePath.GetPointer(), errno, strerror(errno));
146 int ret = unlink(resolvedPath);
155 r = __ConvertNativeErrorToResult(errno);
156 SysLog(NID_IO, "[%s] Failed to unlink(), errno: %d (%s)", GetErrorMessage(r), errno, strerror(errno));
164 _FileUtil::Move(const String& oldFilePath, const String& newFilePath)
166 result r = E_SUCCESS;
167 struct stat64 statBuf;
169 unique_ptr<char[]> pOldPath(_StringConverter::CopyToCharArrayN(oldFilePath));
170 SysTryReturn(NID_IO, pOldPath != null, GetLastResult(), GetLastResult(),
171 "[%s] Invalid old file path.", GetErrorMessage(GetLastResult()));
173 unique_ptr<char[]> pNewPath(_StringConverter::CopyToCharArrayN(newFilePath));
174 SysTryReturn(NID_IO, pNewPath != null, GetLastResult(), GetLastResult(),
175 "[%s] Invalid new file path.", GetErrorMessage(GetLastResult()));
177 SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(newFilePath) == false, E_FILE_ALREADY_EXIST,
178 "New file already exists.");
180 SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(oldFilePath) == true, E_FILE_NOT_FOUND,
181 "Old filepath not found.");
183 if (stat64(pOldPath.get(), &statBuf) < 0)
185 r = __ConvertNativeErrorToResult(errno);
186 SysLogException(NID_IO, r, "[%s] stat64() failed, path: %s, errno: %d (%s)",
187 GetErrorMessage(r), pOldPath.get(), errno, strerror(errno));
190 SysTryReturnResult(NID_IO, S_ISDIR(statBuf.st_mode) == false, E_INVALID_ARG,
191 "The old path is a directory.");
193 int ret = rename(pOldPath.get(), pNewPath.get());
194 if (ret != 0 && errno != EXDEV)
196 r = __ConvertNativeErrorToResult(errno);
197 SysLog(NID_IO, "[%s] rename() failed, errno: %d (%s)", GetErrorMessage(r), errno, strerror(errno));
200 else if (errno == EXDEV)
202 r = File::Copy(oldFilePath, newFilePath, true);
203 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
205 r = File::Remove(oldFilePath);
206 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
213 _FileUtil::Copy(const String& srcFilePath, const String& destFilePath, bool failIfExist)
217 ssize_t readBytes = -1;
218 ssize_t writtenBytes = -1;
219 ssize_t remainingBytes = -1;
220 char* pBuffer = null;
221 char* pCopyBuf = null;
222 result r = E_SUCCESS;
224 unique_ptr<char[]> pSrcpath(_StringConverter::CopyToCharArrayN(srcFilePath));
225 SysTryReturn(NID_IO, pSrcpath != null, GetLastResult(), GetLastResult(),
226 "[%s] Invalid source file path.", GetErrorMessage(GetLastResult()));
228 unique_ptr<char[]> pDstpath(_StringConverter::CopyToCharArrayN(destFilePath));
229 SysTryReturn(NID_IO, pDstpath != null, GetLastResult(), GetLastResult(),
230 "[%s] Invalid destination file path.", GetErrorMessage(GetLastResult()));
232 SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(srcFilePath) == true, E_FILE_NOT_FOUND,
233 "Source file(%s) does not exist.", pSrcpath.get());
235 if ((_FileUtil::IsFileExist(destFilePath) == true) && (failIfExist == true))
237 r = E_FILE_ALREADY_EXIST;
238 SysLog(NID_IO, "[E_FILE_ALREADY_EXIST] Destination file already exists.");
242 srcFd = open64(pSrcpath.get(), O_RDONLY);
245 r = __ConvertNativeErrorToResult(errno);
246 SysLogException(NID_IO, r, "[%s] Failed to open file (%s).", GetErrorMessage(r), pSrcpath.get());
249 dstFd = open64(pDstpath.get(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
252 r = __ConvertNativeErrorToResult(errno);
253 SysLogException(NID_IO, r, "[%s] Failed to open file (%s), errno: %d (%s)",
254 GetErrorMessage(r), pDstpath.get(), errno, strerror(errno));
258 pBuffer = new (std::nothrow) char[_MAX_COPY_BYTES];
259 SysTryCatch(NID_IO, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
266 readBytes = read(srcFd, pCopyBuf, _MAX_COPY_BYTES);
268 while (readBytes < 0 && errno == EINTR);
271 r = __ConvertNativeErrorToResult(errno);
272 SysLogException(NID_IO, r, "[%s] Failed to read from source file (%s), errno: %d (%s)",
273 GetErrorMessage(r), pSrcpath.get(), errno, strerror(errno));
276 else if (readBytes == 0)
280 remainingBytes = readBytes;
284 writtenBytes = write(dstFd, pCopyBuf, remainingBytes);
286 while (writtenBytes < 0 && errno == EINTR);
287 if (writtenBytes < 0)
289 r = __ConvertNativeErrorToResult(errno);
290 SysLogException(NID_IO, r, "[%s] Failed to write to destination file (%s), errno: %d (%s)",
291 GetErrorMessage(r), pDstpath.get(), errno, strerror(errno));
294 else if (writtenBytes < remainingBytes)
296 remainingBytes = remainingBytes - writtenBytes;
297 pCopyBuf = const_cast< char* >(pCopyBuf) + writtenBytes;
320 _FileUtil::GetAttributes(const String& filePath, FileAttributes& attribute)
323 DateTime modifiedTime;
324 off64_t fileSize = 0;
325 unsigned long attr = 0;
326 result r = E_SUCCESS;
327 String fileName = L"";
330 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
331 SysTryReturn(NID_IO, (pFilePath != null), GetLastResult(), GetLastResult(), "[%s] Invalid source file path.",
332 GetErrorMessage(GetLastResult()));
334 struct stat64 statbuf;
335 if (stat64(pFilePath.get(), &statbuf) == -1)
337 r = __ConvertNativeErrorToResult(errno);
338 SysSecureLogException(NID_IO, r, "[%s] Failed to get file (%s) status. errno: %d (%s)",
339 GetErrorMessage(r), pFilePath.get(), errno, strerror(errno));
344 fileSize = statbuf.st_size;
347 attr = statbuf.st_mode;
350 struct tm* pTm = gmtime_r(&statbuf.st_mtime, &resultTm);
351 SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to get local time (%s).", strerror(errno));
353 r = dateTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
354 SysTryReturn(NID_IO, !IsFailed(r), E_SYSTEM, r, "[%s] Failed to set DateTime.", GetErrorMessage(r));
356 r = modifiedTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
357 SysTryReturn(NID_IO, !IsFailed(r), E_SYSTEM, r, "[%s] Failed to set DateTime.", GetErrorMessage(r));
359 LocaleManager locMgr;
362 TimeZone tmZone = locMgr.GetSystemTimeZone();
363 DateTime locDateTime = tmZone.UtcTimeToWallTime(dateTime);
364 DateTime locModifiedTime = tmZone.UtcTimeToWallTime(modifiedTime);
366 fileName = _FileUtil::GetFileName(filePath);
367 if (fileName.StartsWith(L".", 0)) // including . and ..
372 _FileAttributesImpl::GetInstance(attribute)->Set(locDateTime, locModifiedTime, fileSize, attr, hidden);
378 _FileUtil::GetFileName(const String& filePath)
383 result r = filePath.LastIndexOf(L'/', filePath.GetLength() - 1, pos);
384 SysTryReturn(NID_IO, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, fileName, E_INVALID_ARG,
385 "[E_INVALID_ARG] The file path is invalid.");
387 r = filePath.SubString(pos + 1, fileName);
388 SysTryReturn(NID_IO, !IsFailed(r), fileName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
389 SysTryReturn(NID_IO, fileName.GetLength() > 0 && fileName.GetLength() <= NAME_MAX, fileName, E_INVALID_ARG,
390 "[E_INVALID_ARG] The length of file name is zero or exceeds system limitations.");
392 SetLastResult(E_SUCCESS);
397 _FileUtil::GetFileExtension(const String& filePath)
402 result r = filePath.LastIndexOf(L'/', filePath.GetLength() - 1, pos);
403 SysTryReturn(NID_IO, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, extName, E_INVALID_ARG,
404 "[E_INVALID_ARG] The file path is invalid.");
407 r = filePath.SubString(pos + 1, fileName);
408 SysTryReturn(NID_IO, !IsFailed(r), extName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
409 SysTryReturn(NID_IO, fileName.GetLength() > 0 && fileName.GetLength() <= NAME_MAX, extName, E_INVALID_ARG,
410 "[E_INVALID_ARG] The length of file name is zero or exceeds system limitations.");
412 r = fileName.LastIndexOf(L'.', fileName.GetLength() - 1, pos);
413 SysTryReturn(NID_IO, !IsFailed(r), extName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
415 r = fileName.SubString(pos + 1, extName);
416 SysTryReturn(NID_IO, !IsFailed(r), extName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
418 SetLastResult(E_SUCCESS);
423 _FileUtil::IsFileExist(const String& filePath)
426 result r = E_SUCCESS;
428 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
429 SysTryReturn(NID_IO, (pFilePath != null), false, GetLastResult(), ("[%s] Invalid file path."),
430 GetErrorMessage(GetLastResult()));
432 ret = access(pFilePath.get(), F_OK);
444 r = __ConvertNativeErrorToResult(errno);
450 return (ret == 0) ? true : false;
455 _FileUtil::IsEncrypted(const String& filePath)
457 result r = E_SUCCESS;
458 // TODO: int pathKind;
461 bool encrypted = false;
462 // TODO: bool checkPrivilege = false;
463 byte secureHeader[SECURE_FILE_HEADER_SIZE_V1 + SECURE_IO_LOF_SIZE];
464 byte reservedValue[SECURE_IO_STATIC_BIN_LEN] = {0xCA, 0xFE, 0xBE, 0xBE, 0xDA, 0xEF, 0xEB, 0xEB};
465 char magicNum1[SECURE_IO_MAGIC_NUMBER_SIZE] = {0xCA, 0xFE, 0xBE, 0xBE};
466 char magicNum2[SECURE_IO_MAGIC_NUMBER_SIZE] = {0xDA, 0xEF, 0xEF, 0xEB};
469 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
470 SysTryReturn(NID_IO, pFilePath != null, false, E_INVALID_ARG, "[E_INVALID_ARG] CopyToCharArrayN failed!");
472 fileLength = strlen(pFilePath.get());
473 SysTryReturn(NID_IO, fileLength > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] CopyToCharArrayN failed!");
475 if (pFilePath[fileLength - 1] == ('/'))
477 pFilePath[fileLength - 1] = ('\0'); // remove last '/' character if exists.
480 // // TODO: check accessibility to path
481 // r = CheckAccessibilityToPath(pFilePath, &pathKind, 0);
485 // if(pathKind == __PATH_KIND_AUTHORIZED_MMC)
487 // __CheckPrivilege(PRV_INSTALLATION, checkPrivilege);
488 // if(!checkPrivilege)
490 // r = E_ILLEGAL_ACCESS;
494 // else if(pathKind == __PATH_KIND_AUTHORIZED_LINK || pathKind == __PATH_KIND_AUTHORIZED_NPKI ||
495 // pathKind == __PATH_KIND_AUTHORIZED_PRELOADED_MEDIA)
497 // __CheckPrivilege(PRV_PRIVILEGED_IO, checkPrivilege);
498 // if(!checkPrivilege)
500 // r = E_ILLEGAL_ACCESS;
504 // else if (pathKind == __PATH_KIND_APP_DENY)
506 // r = E_ILLEGAL_ACCESS;
510 pFile = fopen(pFilePath.get(), "r");
513 r = __ConvertNativeErrorToResult(errno);
514 SysLog(NID_IO, "[%s] Failed to open file (%s) in openMode (%s), (errno: %d).", GetErrorMessage(r), pFilePath.get(), "r", errno);
518 readItems = fread(secureHeader, 1, SECURE_FILE_HEADER_SIZE_V1 + SECURE_IO_LOF_SIZE, pFile);
520 if (readItems < (SECURE_FILE_HEADER_SIZE_V1 + SECURE_IO_LOF_SIZE))
522 int eof = feof((FILE*)pFile);
530 r = __ConvertNativeErrorToResult(errno);
531 SysLog(NID_IO, "[%s] Failed to open file (%s) in openMode (%s), (errno: %d).", GetErrorMessage(r), pFilePath.get(), "r", errno);
535 if (memcmp(secureHeader, SECURE_FILE_HEADER_STRING, SECURE_FILE_HEADER_STRING_SIZE) == 0 && \
536 memcmp(secureHeader + SECURE_FILE_HEADER_STRING_SIZE, reservedValue, SECURE_IO_STATIC_BIN_LEN) == 0)
540 else if (memcmp(secureHeader, SECURE_REG_HEADER_STRING, SECURE_REG_HEADER_STRING_SIZE) == 0 && \
541 memcmp(secureHeader + SECURE_REG_HEADER_STRING_SIZE, reservedValue, SECURE_IO_STATIC_BIN_LEN) == 0)
545 else if ((memcmp(secureHeader, magicNum1, SECURE_IO_MAGIC_NUMBER_SIZE) == 0) &&
546 (memcmp(secureHeader + SECURE_IO_STATIC_BIN_LEN, magicNum2, SECURE_IO_MAGIC_NUMBER_SIZE) == 0))
570 _FileUtil::IsAppPath(const String& filePath)
572 result r = E_SUCCESS;
574 if (VerifyFilePath(filePath, FILEPATH_TYPE_APP))
576 SetLastResult(E_SUCCESS);
586 _FileUtil::IsMediaPath(const String& filePath)
588 result r = E_SUCCESS;
590 if (VerifyFilePath(filePath, FILEPATH_TYPE_MEDIA))
592 SetLastResult(E_SUCCESS);
602 _FileUtil::IsSystemPath(const String& filePath)
604 result r = E_SUCCESS;
606 if (VerifyFilePath(filePath, FILEPATH_TYPE_SYSTEM))
608 SetLastResult(E_SUCCESS);
618 _FileUtil::VerifyFilePath(const String& filePath, _FilePathType pathType)
620 result r = E_SUCCESS;
622 String absolutePath("");
626 char** ppPathList = null;
627 bool candidateFound = false;
630 //TODO Apply realpath after data caging.
632 //char resolved_path[1024];
633 //char* pFilePath = _StringConverter::CopyToCharArrayN(filePath);
635 //r = GetLastResult();
637 //SysTryCatch(NID_IO, pFilePath != null,
638 // r, r, "[%s] Failed to get file path", GetErrorMessage(r));
641 //SysLog(NID_IO, "convert: %s", pFilePath);
642 //if (realpath(pFilePath, resolved_path) !=0)
644 // r = __ConvertNativeErrorToResult(errno);
645 // SysLog(NID_IO, "convert Error!!! [%s] %s", resolved_path, GetErrorMessage(r));
646 // delete[] pFilePath;
650 //SysLog(NID_IO, "convert result: %s", resolved_path);
651 //absolutePath.Append(resolved_path);
652 //delete[] pFilePath;
654 absolutePath.Append(filePath);
655 // This code does not handle paths without prefix '/' ex: "Home/myfile"
656 // since it depends on cwd.
659 case FILEPATH_TYPE_APP:
660 pathCount = MAX_FILEPATH_APP;
661 ppPathList = const_cast <char**>(filePathAppPrefix);
664 case FILEPATH_TYPE_MEDIA:
665 pathCount = MAX_FILEPATH_MEDIA;
666 ppPathList = const_cast <char**>(filePathMediaPrefix);
669 case FILEPATH_TYPE_SYSTEM:
670 pathCount = MAX_FILEPATH_SYSTEM;
671 ppPathList = const_cast <char**>(filePathSystemPrefix);
679 absolutePath.GetCharAt(absolutePath.GetLength() - 1, ch);
680 if (ch != L'/') // if last char of absolutePath is not '/' then append it to make path parsing easier
682 absolutePath.Append(L'/');
685 for (i = 0; i < pathCount; i++)
688 tmpStr.Append(ppPathList[i]);
690 if (absolutePath.IndexOf(tmpStr, 0, index) == E_SUCCESS)
695 if (absolutePath.GetCharAt(tmpStr.GetLength(), ch) == E_SUCCESS)
697 if (ch == L'/') // validate exact path. paths like /Home123/file.txt is not supported.
699 candidateFound = true;
707 if (candidateFound == true)
729 _FileUtil::ConvertToSecureFile(const String& plainFilePath, const String& secureFilePath, const ByteBuffer* pKey)
731 SysTryReturnResult(NID_IO, plainFilePath.GetLength() > 0 && plainFilePath.GetLength() <= PATH_MAX, E_INVALID_ARG,
732 "Invalid argument was passed. Given file name length is not correct!");
733 SysTryReturnResult(NID_IO, plainFilePath.EndsWith(L"/") == false, E_INVALID_ARG,
734 "Invalid argument was passed. Given file name is not correct! - ends with '/'");
736 SysTryReturnResult(NID_IO, secureFilePath.GetLength() > 0 && secureFilePath.GetLength() <= PATH_MAX, E_INVALID_ARG,
737 "Invalid argument was passed. Given file name length is not correct!");
738 SysTryReturnResult(NID_IO, secureFilePath.EndsWith(L"/") == false, E_INVALID_ARG,
739 "Invalid argument was passed. Given file name is not correct! - ends with '/'");
743 int lastBlockSize = 0;
747 unique_ptr<byte[]> pBuffer(null);
748 result r = E_SUCCESS;
750 if (File::IsFileExist(secureFilePath))
755 r = E_FILE_ALREADY_EXIST;
756 SysLog(NID_IO, "[E_FILE_ALREADY_EXIST] The secure file already exist.");
760 SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
765 unique_ptr<File> pFile(new (std::nothrow) File());
766 SysTryReturnResult(NID_IO, pFile != null, E_OUT_OF_MEMORY, "Unable to create Io::File");
768 r = pFile->Construct(plainFilePath, L"r", false);
771 if (r == E_MAX_EXCEEDED)
775 SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
779 r = pFile->Seek(FILESEEKPOSITION_END, 0);
780 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));
782 fileSize = pFile->Tell();
784 r = pFile->Seek(FILESEEKPOSITION_BEGIN, 0);
785 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));
787 unique_ptr<File> pSecureFile(new (std::nothrow) File());
788 SysTryReturnResult(NID_IO, pSecureFile != null, E_OUT_OF_MEMORY,
789 "Unable to create Io::File");
791 r = pSecureFile->Construct(secureFilePath, "w", *pKey);
792 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));
799 lastBlockSize = fileSize % CIPHER_BLOCK_SIZE;
800 if (lastBlockSize == 0)
802 blockCount = fileSize / CIPHER_BLOCK_SIZE;
803 lastBlockSize = CIPHER_BLOCK_SIZE;
807 blockCount = fileSize / CIPHER_BLOCK_SIZE + 1;
810 for(count = 0; count < blockCount; count++)
814 memset(pBuffer.get(), 0, CIPHER_BLOCK_SIZE);
817 if ((count + 1) == blockCount && pBuffer == null)
819 pBuffer.reset(new (std::nothrow) byte[lastBlockSize]);
820 SysTryReturnResult(NID_IO, pBuffer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
821 memset(pBuffer.get(), 0, lastBlockSize);
822 bufferSize = lastBlockSize;
825 else if ((count + 1) != blockCount && pBuffer == null)
827 pBuffer.reset(new (std::nothrow) byte[CIPHER_BLOCK_SIZE]);
828 SysTryReturnResult(NID_IO, pBuffer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
829 memset(pBuffer.get(), 0, CIPHER_BLOCK_SIZE);
830 bufferSize = CIPHER_BLOCK_SIZE;
833 readSize = pFile->Read(pBuffer.get(), bufferSize);
837 if (r == E_END_OF_FILE)
841 SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
845 r = pSecureFile->Write(pBuffer.get(), readSize);
846 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));