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>
40 #include <FBase_StringConverter.h>
41 #include <FBase_NativeError.h>
42 #include <FApp_AppInfo.h>
43 #include <FIo_FileAttributesImpl.h>
44 #include <FIo_SecureIoUtil.h>
45 #include <FIo_FileImpl.h>
46 #include <FIo_FileUtil.h>
49 using namespace Tizen::Base;
50 using namespace Tizen::App;
52 namespace Tizen { namespace Io
55 static const int _BASE_YEAR = 1900;
56 static const int _MAX_COPY_BYTES = 4096;
57 static const int _MAX_OPENMODE_LENGTH = 3;
59 //Holds app path prefixes
60 static const char* filePathAppPrefix[] =
74 "/Storagecard/DownloadedAppPackages",
82 //Holds Media path prefixes
83 static const char* filePathMediaPrefix[] =
89 //Holds system path prefixes
90 static const char* filePathSystemPrefix[] =
92 "/system/configuration",
97 _FileUtil::Remove(const String& filePath)
100 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
101 SysTryReturn(NID_IO, (pFilePath != null), GetLastResult(), GetLastResult(), ("[%s] Invalid file path."),
102 GetErrorMessage(GetLastResult()));
104 if (_FileUtil::IsFileExist(pFilePath.get()) == false)
106 SysSecureLogException(NID_IO, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] File (%s) does not exist.", pFilePath.get());
107 return E_FILE_NOT_FOUND;
110 char resolvedPath[PATH_MAX] = {0,};
111 if (realpath(pFilePath.get(), resolvedPath) == null)
116 r = E_ILLEGAL_ACCESS;
131 r = E_FILE_NOT_FOUND;
138 SysLog(NID_IO, "[%s] Failed to produce canonical absolute path (%ls). errno: %d (%s)",
139 GetErrorMessage(r), filePath.GetPointer(), errno, strerror(errno));
144 int ret = unlink(resolvedPath);
153 r = __ConvertNativeErrorToResult(errno);
154 SysLog(NID_IO, "[%s] Failed to unlink(), errno: %d (%s)", GetErrorMessage(r), errno, strerror(errno));
162 _FileUtil::Move(const String& oldFilePath, const String& newFilePath)
164 result r = E_SUCCESS;
165 struct stat64 statBuf;
167 unique_ptr<char[]> pOldPath(_StringConverter::CopyToCharArrayN(oldFilePath));
168 SysTryReturn(NID_IO, pOldPath != null, GetLastResult(), GetLastResult(),
169 "[%s] Invalid old file path.", GetErrorMessage(GetLastResult()));
171 unique_ptr<char[]> pNewPath(_StringConverter::CopyToCharArrayN(newFilePath));
172 SysTryReturn(NID_IO, pNewPath != null, GetLastResult(), GetLastResult(),
173 "[%s] Invalid new file path.", GetErrorMessage(GetLastResult()));
175 SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(newFilePath) == false, E_FILE_ALREADY_EXIST,
176 "New file already exists.");
178 SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(oldFilePath) == true, E_FILE_NOT_FOUND,
179 "Old filepath not found.");
181 if (stat64(pOldPath.get(), &statBuf) < 0)
183 r = __ConvertNativeErrorToResult(errno);
184 SysLogException(NID_IO, r, "[%s] stat64() failed, path: %s, errno: %d (%s)",
185 GetErrorMessage(r), pOldPath.get(), errno, strerror(errno));
188 SysTryReturnResult(NID_IO, S_ISDIR(statBuf.st_mode) == false, E_INVALID_ARG,
189 "The old path is a directory.");
191 int ret = rename(pOldPath.get(), pNewPath.get());
192 if (ret != 0 && errno != EXDEV)
194 r = __ConvertNativeErrorToResult(errno);
195 SysLog(NID_IO, "[%s] rename() failed, errno: %d (%s)", GetErrorMessage(r), errno, strerror(errno));
198 else if (errno == EXDEV)
200 r = File::Copy(oldFilePath, newFilePath, true);
201 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
203 r = File::Remove(oldFilePath);
204 SysTryReturn(NID_IO, !IsFailed(r), r, r, "[%s] Propagating to caller...", GetErrorMessage(r));
211 _FileUtil::Copy(const String& srcFilePath, const String& destFilePath, bool failIfExist)
215 ssize_t readBytes = -1;
216 ssize_t writtenBytes = -1;
217 ssize_t remainingBytes = -1;
218 char* pBuffer = null;
219 char* pCopyBuf = null;
220 result r = E_SUCCESS;
222 unique_ptr<char[]> pSrcpath(_StringConverter::CopyToCharArrayN(srcFilePath));
223 SysTryReturn(NID_IO, pSrcpath != null, GetLastResult(), GetLastResult(),
224 "[%s] Invalid source file path.", GetErrorMessage(GetLastResult()));
226 unique_ptr<char[]> pDstpath(_StringConverter::CopyToCharArrayN(destFilePath));
227 SysTryReturn(NID_IO, pDstpath != null, GetLastResult(), GetLastResult(),
228 "[%s] Invalid destination file path.", GetErrorMessage(GetLastResult()));
230 SysTryReturnResult(NID_IO, _FileUtil::IsFileExist(srcFilePath) == true, E_FILE_NOT_FOUND,
231 "Source file(%s) does not exist.", pSrcpath.get());
233 if ((_FileUtil::IsFileExist(destFilePath) == true) && (failIfExist == true))
235 r = E_FILE_ALREADY_EXIST;
236 SysLog(NID_IO, "[E_FILE_ALREADY_EXIST] Destination file already exists.");
240 srcFd = open64(pSrcpath.get(), O_RDONLY);
243 r = __ConvertNativeErrorToResult(errno);
244 SysLogException(NID_IO, r, "[%s] Failed to open file (%s).", GetErrorMessage(r), pSrcpath.get());
247 dstFd = open64(pDstpath.get(), O_WRONLY | O_CREAT | O_TRUNC, 0644);
250 r = __ConvertNativeErrorToResult(errno);
251 SysLogException(NID_IO, r, "[%s] Failed to open file (%s), errno: %d (%s)",
252 GetErrorMessage(r), pDstpath.get(), errno, strerror(errno));
256 pBuffer = new (std::nothrow) char[_MAX_COPY_BYTES];
257 SysTryCatch(NID_IO, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
264 readBytes = read(srcFd, pCopyBuf, _MAX_COPY_BYTES);
266 while (readBytes < 0 && errno == EINTR);
269 r = __ConvertNativeErrorToResult(errno);
270 SysLogException(NID_IO, r, "[%s] Failed to read from source file (%s), errno: %d (%s)",
271 GetErrorMessage(r), pSrcpath.get(), errno, strerror(errno));
274 else if (readBytes == 0)
278 remainingBytes = readBytes;
282 writtenBytes = write(dstFd, pCopyBuf, remainingBytes);
284 while (writtenBytes < 0 && errno == EINTR);
285 if (writtenBytes < 0)
287 r = __ConvertNativeErrorToResult(errno);
288 SysLogException(NID_IO, r, "[%s] Failed to write to destination file (%s), errno: %d (%s)",
289 GetErrorMessage(r), pDstpath.get(), errno, strerror(errno));
292 else if (writtenBytes < remainingBytes)
294 remainingBytes = remainingBytes - writtenBytes;
295 pCopyBuf = const_cast< char* >(pCopyBuf) + writtenBytes;
318 _FileUtil::GetAttributes(const String& filePath, FileAttributes& attribute)
321 DateTime modifiedTime;
322 off64_t fileSize = 0;
323 unsigned long attr = 0;
324 result r = E_SUCCESS;
325 struct tm* pTm = null;
326 String fileName = L"";
329 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
330 SysTryReturn(NID_IO, (pFilePath != null), GetLastResult(), GetLastResult(), "[%s] Invalid source file path.",
331 GetErrorMessage(GetLastResult()));
333 struct stat64 statbuf;
334 if (int ret = stat64(pFilePath.get(), &statbuf) == -1)
336 r = __ConvertNativeErrorToResult(errno);
337 SysLogException(NID_IO, r, "[%s] Failed to get file (%s) status.", GetErrorMessage(r), pFilePath.get());
342 fileSize = statbuf.st_size;
345 attr = statbuf.st_mode;
347 pTm = localtime(&statbuf.st_mtime);
348 SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno));
349 r = dateTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
350 SysTryReturn(NID_IO, (!IsFailed(r)), r, r, "[%s] Failed to set DateTime.", GetErrorMessage(r));
352 pTm = localtime(&statbuf.st_mtime);
353 SysTryReturnResult(NID_IO, pTm != null, E_SYSTEM, "Failed to call localtime() (%s).", strerror(errno));
354 r = modifiedTime.SetValue(_BASE_YEAR + pTm->tm_year, 1 + pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec);
355 SysTryReturn(NID_IO, (!IsFailed(r)), r, r, "[%s] Failed to set DateTime.", GetErrorMessage(r));
357 fileName = _FileUtil::GetFileName(filePath);
358 if (fileName.StartsWith(L".", 0)) // including . and ..
363 _FileAttributesImpl::GetInstance(attribute)->Set(dateTime, modifiedTime, fileSize, attr, hidden);
369 _FileUtil::GetFileName(const String& filePath)
374 result r = filePath.LastIndexOf(L'/', filePath.GetLength() - 1, pos);
375 SysTryReturn(NID_IO, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, fileName, E_INVALID_ARG,
376 "[E_INVALID_ARG] The file path is invalid.");
378 r = filePath.SubString(pos + 1, fileName);
379 SysTryReturn(NID_IO, !IsFailed(r), fileName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
380 SysTryReturn(NID_IO, fileName.GetLength() > 0 && fileName.GetLength() <= NAME_MAX, fileName, E_INVALID_ARG,
381 "[E_INVALID_ARG] The length of file name is zero or exceeds system limitations.");
383 SetLastResult(E_SUCCESS);
388 _FileUtil::GetFileExtension(const String& filePath)
393 result r = filePath.LastIndexOf(L'/', filePath.GetLength() - 1, pos);
394 SysTryReturn(NID_IO, r == E_SUCCESS || r == E_OBJ_NOT_FOUND, extName, E_INVALID_ARG,
395 "[E_INVALID_ARG] The file path is invalid.");
398 r = filePath.SubString(pos + 1, fileName);
399 SysTryReturn(NID_IO, !IsFailed(r), extName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
400 SysTryReturn(NID_IO, fileName.GetLength() > 0 && fileName.GetLength() <= NAME_MAX, extName, E_INVALID_ARG,
401 "[E_INVALID_ARG] The length of file name is zero or exceeds system limitations.");
403 r = fileName.LastIndexOf(L'.', fileName.GetLength() - 1, pos);
404 SysTryReturn(NID_IO, !IsFailed(r), extName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
406 r = fileName.SubString(pos + 1, extName);
407 SysTryReturn(NID_IO, !IsFailed(r), extName, E_INVALID_ARG, "[E_INVALID_ARG] The file path is invalid.");
409 SetLastResult(E_SUCCESS);
414 _FileUtil::IsFileExist(const String& filePath)
417 result r = E_SUCCESS;
419 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
420 SysTryReturn(NID_IO, (pFilePath != null), false, GetLastResult(), ("[%s] Invalid file path."),
421 GetErrorMessage(GetLastResult()));
423 ret = access(pFilePath.get(), F_OK);
435 r = __ConvertNativeErrorToResult(errno);
441 return (ret == 0) ? true : false;
446 _FileUtil::IsEncrypted(const String& filePath)
448 result r = E_SUCCESS;
449 // TODO: int pathKind;
452 bool encrypted = false;
453 // TODO: bool checkPrivilege = false;
454 byte secureHeader[SECURE_FILE_HEADER_SIZE_V1 + SECURE_IO_LOF_SIZE];
455 byte reservedValue[SECURE_IO_STATIC_BIN_LEN] = {0xCA, 0xFE, 0xBE, 0xBE, 0xDA, 0xEF, 0xEB, 0xEB};
456 char magicNum1[SECURE_IO_MAGIC_NUMBER_SIZE] = {0xCA, 0xFE, 0xBE, 0xBE};
457 char magicNum2[SECURE_IO_MAGIC_NUMBER_SIZE] = {0xDA, 0xEF, 0xEF, 0xEB};
460 unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath));
461 SysTryReturn(NID_IO, pFilePath != null, false, E_INVALID_ARG, "[E_INVALID_ARG] CopyToCharArrayN failed!");
463 fileLength = strlen(pFilePath.get());
464 SysTryReturn(NID_IO, fileLength > 0, false, E_INVALID_ARG, "[E_INVALID_ARG] CopyToCharArrayN failed!");
466 if (pFilePath[fileLength - 1] == ('/'))
468 pFilePath[fileLength - 1] = ('\0'); // remove last '/' character if exists.
471 // // TODO: check accessibility to path
472 // r = CheckAccessibilityToPath(pFilePath, &pathKind, 0);
476 // if(pathKind == __PATH_KIND_AUTHORIZED_MMC)
478 // __CheckPrivilege(PRV_INSTALLATION, checkPrivilege);
479 // if(!checkPrivilege)
481 // r = E_ILLEGAL_ACCESS;
485 // else if(pathKind == __PATH_KIND_AUTHORIZED_LINK || pathKind == __PATH_KIND_AUTHORIZED_NPKI ||
486 // pathKind == __PATH_KIND_AUTHORIZED_PRELOADED_MEDIA)
488 // __CheckPrivilege(PRV_PRIVILEGED_IO, checkPrivilege);
489 // if(!checkPrivilege)
491 // r = E_ILLEGAL_ACCESS;
495 // else if (pathKind == __PATH_KIND_APP_DENY)
497 // r = E_ILLEGAL_ACCESS;
501 pFile = fopen(pFilePath.get(), "r");
504 r = __ConvertNativeErrorToResult(errno);
505 SysLog(NID_IO, "[%s] Failed to open file (%s) in openMode (%s), (errno: %d).", GetErrorMessage(r), pFilePath.get(), "r", errno);
509 readItems = fread(secureHeader, 1, SECURE_FILE_HEADER_SIZE_V1 + SECURE_IO_LOF_SIZE, pFile);
511 if (readItems < (SECURE_FILE_HEADER_SIZE_V1 + SECURE_IO_LOF_SIZE))
513 int eof = feof((FILE*)pFile);
521 r = __ConvertNativeErrorToResult(errno);
522 SysLog(NID_IO, "[%s] Failed to open file (%s) in openMode (%s), (errno: %d).", GetErrorMessage(r), pFilePath.get(), "r", errno);
526 if (memcmp(secureHeader, SECURE_FILE_HEADER_STRING, SECURE_FILE_HEADER_STRING_SIZE) == 0 && \
527 memcmp(secureHeader + SECURE_FILE_HEADER_STRING_SIZE, reservedValue, SECURE_IO_STATIC_BIN_LEN) == 0)
531 else if (memcmp(secureHeader, SECURE_REG_HEADER_STRING, SECURE_REG_HEADER_STRING_SIZE) == 0 && \
532 memcmp(secureHeader + SECURE_REG_HEADER_STRING_SIZE, reservedValue, SECURE_IO_STATIC_BIN_LEN) == 0)
536 else if ((memcmp(secureHeader, magicNum1, SECURE_IO_MAGIC_NUMBER_SIZE) == 0) &&
537 (memcmp(secureHeader + SECURE_IO_STATIC_BIN_LEN, magicNum2, SECURE_IO_MAGIC_NUMBER_SIZE) == 0))
561 _FileUtil::IsAppPath(const String& filePath)
563 result r = E_SUCCESS;
565 if (VerifyFilePath(filePath, FILEPATH_TYPE_APP))
567 SetLastResult(E_SUCCESS);
577 _FileUtil::IsMediaPath(const String& filePath)
579 result r = E_SUCCESS;
581 if (VerifyFilePath(filePath, FILEPATH_TYPE_MEDIA))
583 SetLastResult(E_SUCCESS);
593 _FileUtil::IsSystemPath(const String& filePath)
595 result r = E_SUCCESS;
597 if (VerifyFilePath(filePath, FILEPATH_TYPE_SYSTEM))
599 SetLastResult(E_SUCCESS);
609 _FileUtil::VerifyFilePath(const String& filePath, _FilePathType pathType)
611 result r = E_SUCCESS;
613 String absolutePath("");
617 char** ppPathList = null;
618 bool candidateFound = false;
621 //TODO Apply realpath after data caging.
623 //char resolved_path[1024];
624 //char* pFilePath = _StringConverter::CopyToCharArrayN(filePath);
626 //r = GetLastResult();
628 //SysTryCatch(NID_IO, pFilePath != null,
629 // r, r, "[%s] Failed to get file path", GetErrorMessage(r));
632 //SysLog(NID_IO, "convert: %s", pFilePath);
633 //if (realpath(pFilePath, resolved_path) !=0)
635 // r = __ConvertNativeErrorToResult(errno);
636 // SysLog(NID_IO, "convert Error!!! [%s] %s", resolved_path, GetErrorMessage(r));
637 // delete[] pFilePath;
641 //SysLog(NID_IO, "convert result: %s", resolved_path);
642 //absolutePath.Append(resolved_path);
643 //delete[] pFilePath;
645 absolutePath.Append(filePath);
646 // This code does not handle paths without prefix '/' ex: "Home/myfile"
647 // since it depends on cwd.
650 case FILEPATH_TYPE_APP:
651 pathCount = MAX_FILEPATH_APP;
652 ppPathList = const_cast <char**>(filePathAppPrefix);
655 case FILEPATH_TYPE_MEDIA:
656 pathCount = MAX_FILEPATH_MEDIA;
657 ppPathList = const_cast <char**>(filePathMediaPrefix);
660 case FILEPATH_TYPE_SYSTEM:
661 pathCount = MAX_FILEPATH_SYSTEM;
662 ppPathList = const_cast <char**>(filePathSystemPrefix);
670 absolutePath.GetCharAt(absolutePath.GetLength() - 1, ch);
671 if (ch != L'/') // if last char of absolutePath is not '/' then append it to make path parsing easier
673 absolutePath.Append(L'/');
676 for (i = 0; i < pathCount; i++)
679 tmpStr.Append(ppPathList[i]);
681 if (absolutePath.IndexOf(tmpStr, 0, index) == E_SUCCESS)
686 if (absolutePath.GetCharAt(tmpStr.GetLength(), ch) == E_SUCCESS)
688 if (ch == L'/') // validate exact path. paths like /Home123/file.txt is not supported.
690 candidateFound = true;
698 if (candidateFound == true)
720 _FileUtil::ConvertToSecureFile(const String& plainFilePath, const String& secureFilePath, const ByteBuffer* pKey)
722 SysTryReturnResult(NID_IO, plainFilePath.GetLength() > 0 && plainFilePath.GetLength() <= PATH_MAX, E_INVALID_ARG,
723 "Invalid argument was passed. Given file name length is not correct!");
724 SysTryReturnResult(NID_IO, plainFilePath.EndsWith(L"/") == false, E_INVALID_ARG,
725 "Invalid argument was passed. Given file name is not correct! - ends with '/'");
727 SysTryReturnResult(NID_IO, secureFilePath.GetLength() > 0 && secureFilePath.GetLength() <= PATH_MAX, E_INVALID_ARG,
728 "Invalid argument was passed. Given file name length is not correct!");
729 SysTryReturnResult(NID_IO, secureFilePath.EndsWith(L"/") == false, E_INVALID_ARG,
730 "Invalid argument was passed. Given file name is not correct! - ends with '/'");
734 int lastBlockSize = 0;
738 unique_ptr<byte[]> pBuffer(null);
739 result r = E_SUCCESS;
741 if (File::IsFileExist(secureFilePath))
746 r = E_FILE_ALREADY_EXIST;
747 SysLog(NID_IO, "[E_FILE_ALREADY_EXIST] The secure file already exist.");
751 SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
756 unique_ptr<File> pFile(new (std::nothrow) File());
757 SysTryReturnResult(NID_IO, pFile != null, E_OUT_OF_MEMORY, "Unable to create Io::File");
759 r = pFile->Construct(plainFilePath, L"r", false);
762 if (r == E_MAX_EXCEEDED)
766 SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
770 r = pFile->Seek(FILESEEKPOSITION_END, 0);
771 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));
773 fileSize = pFile->Tell();
775 r = pFile->Seek(FILESEEKPOSITION_BEGIN, 0);
776 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));
778 unique_ptr<File> pSecureFile(new (std::nothrow) File());
779 SysTryReturnResult(NID_IO, pSecureFile != null, E_OUT_OF_MEMORY,
780 "Unable to create Io::File");
782 r = pSecureFile->Construct(secureFilePath, "w", *pKey);
783 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));
790 lastBlockSize = fileSize % CIPHER_BLOCK_SIZE;
791 if (lastBlockSize == 0)
793 blockCount = fileSize / CIPHER_BLOCK_SIZE;
794 lastBlockSize = CIPHER_BLOCK_SIZE;
798 blockCount = fileSize / CIPHER_BLOCK_SIZE + 1;
801 for(count = 0; count < blockCount; count++)
805 memset(pBuffer.get(), 0, CIPHER_BLOCK_SIZE);
808 if ((count + 1) == blockCount && pBuffer == null)
810 pBuffer.reset(new (std::nothrow) byte[lastBlockSize]);
811 SysTryReturnResult(NID_IO, pBuffer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
812 memset(pBuffer.get(), 0, lastBlockSize);
813 bufferSize = lastBlockSize;
816 else if ((count + 1) != blockCount && pBuffer == null)
818 pBuffer.reset(new (std::nothrow) byte[CIPHER_BLOCK_SIZE]);
819 SysTryReturnResult(NID_IO, pBuffer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
820 memset(pBuffer.get(), 0, CIPHER_BLOCK_SIZE);
821 bufferSize = CIPHER_BLOCK_SIZE;
824 readSize = pFile->Read(pBuffer.get(), bufferSize);
828 if (r == E_END_OF_FILE)
832 SysLog(NID_IO, "[%s] Propagated.", GetErrorMessage(r));
836 r = pSecureFile->Write(pBuffer.get(), readSize);
837 SysTryReturn(NID_IO, r == E_SUCCESS , r, r, "[%s] Propagated", GetErrorMessage(r));