From: Jihye Kang Date: Tue, 9 Apr 2013 15:27:03 +0000 (+0900) Subject: Make FileWriter writes from current position and change failure condition X-Git-Tag: 2.1_release~142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b500952c796287d0d48ec0c20a563488be27169;p=framework%2Fweb%2Fwebkit-efl.git Make FileWriter writes from current position and change failure condition [Title] Make FileWriter writes from current position and fire error type progress event when written bytes are less than expectation [Issue#] N/A [Problem] [Cause] [Solution] - OpenFile without O_TRUNC option for avoiding data crash of file with lseek and write - Seek to the position before start to write - Make SECURITY_ERR when write operation is completed but bytes of written is not equal to the expectation Change-Id: I1806c2df80f7745b7f5a7efd28dee78455d7f54d --- diff --git a/Source/WebCore/platform/FileSystem.h b/Source/WebCore/platform/FileSystem.h index 7529d20..867f820 100644 --- a/Source/WebCore/platform/FileSystem.h +++ b/Source/WebCore/platform/FileSystem.h @@ -144,6 +144,9 @@ const PlatformFileHandle invalidPlatformFileHandle = -1; enum FileOpenMode { OpenForRead = 0, OpenForWrite +#if ENABLE(TIZEN_FILE_SYSTEM) + , OpenForWriteOnly +#endif }; enum FileSeekOrigin { diff --git a/Source/WebCore/platform/efl/tizen/AsyncFileWriterTizen.cpp b/Source/WebCore/platform/efl/tizen/AsyncFileWriterTizen.cpp index 2925e1f..5797496 100644 --- a/Source/WebCore/platform/efl/tizen/AsyncFileWriterTizen.cpp +++ b/Source/WebCore/platform/efl/tizen/AsyncFileWriterTizen.cpp @@ -47,7 +47,7 @@ static void writeAsync(ScriptExecutionContext* context, PassOwnPtrdidFail(FileError::NOT_FOUND_ERR); @@ -61,6 +61,7 @@ static void writeAsync(ScriptExecutionContext* context, PassOwnPtr blobStorage = static_cast(blobRegistry()).getBlobDataFromURL(data->url()); if (blobStorage) { for (size_t i = 0; i < blobStorage->items().size(); i++) { @@ -69,7 +70,7 @@ static void writeAsync(ScriptExecutionContext* context, PassOwnPtrdata(), blobItem.data->length()); - if (bytesWritten < 0) + if (bytesWritten != blobItem.data->length()) helperClient->didFail(FileError::SECURITY_ERR); else helperClient->didWrite(bytesWritten, (i + 1 == blobStorage->items().size()) ? true : false); diff --git a/Source/WebCore/platform/efl/tizen/FileSystemTizen.cpp b/Source/WebCore/platform/efl/tizen/FileSystemTizen.cpp index 731e711..1d84bb8 100644 --- a/Source/WebCore/platform/efl/tizen/FileSystemTizen.cpp +++ b/Source/WebCore/platform/efl/tizen/FileSystemTizen.cpp @@ -32,6 +32,7 @@ #if ENABLE(TIZEN_FILE_SYSTEM) #include "FileMetadata.h" #include +#include #include #include #include @@ -105,6 +106,23 @@ bool linkFile(const String& sourcePath, const String& destinationPath) return !link(fsRepSource.data(), fsRepDestination.data()); } +PlatformFileHandle openFile(const String& path, FileOpenMode mode) +{ + CString fsRep = fileSystemRepresentation(path); + + if (fsRep.isNull()) + return invalidPlatformFileHandle; + + int platformFlag = 0; + if (mode == OpenForRead) + platformFlag |= O_RDONLY; + else if (mode == OpenForWrite) + platformFlag |= (O_WRONLY | O_CREAT | O_TRUNC); + else if (mode == OpenForWriteOnly) + platformFlag |= (O_WRONLY); + return open(fsRep.data(), platformFlag, 0666); +} + bool renameFile(const String& sourcePath, const String& destinationPath) { CString fsRepSource = fileSystemRepresentation(sourcePath); diff --git a/Source/WebCore/platform/posix/FileSystemPOSIX.cpp b/Source/WebCore/platform/posix/FileSystemPOSIX.cpp index 08d711f..7b9df88 100644 --- a/Source/WebCore/platform/posix/FileSystemPOSIX.cpp +++ b/Source/WebCore/platform/posix/FileSystemPOSIX.cpp @@ -76,6 +76,7 @@ bool deleteFile(const String& path) return !unlink(fsRep.data()); } +#if !ENABLE(TIZEN_FILE_SYSTEM) PlatformFileHandle openFile(const String& path, FileOpenMode mode) { CString fsRep = fileSystemRepresentation(path); @@ -90,6 +91,7 @@ PlatformFileHandle openFile(const String& path, FileOpenMode mode) platformFlag |= (O_WRONLY | O_CREAT | O_TRUNC); return open(fsRep.data(), platformFlag, 0666); } +#endif void closeFile(PlatformFileHandle& handle) {