Changeset 201796 in webkit


Ignore:
Timestamp:
Jun 7, 2016 11:51:51 PM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[GLIB] Implement hardLinkOrCopyFile() in FileSystemGlib
https://bugs.webkit.org/show_bug.cgi?id=158473

Reviewed by Michael Catanzaro.

It was added in r199230 to be used by IndexedDB blob support, but never implemented for GLib.

  • platform/glib/FileSystemGlib.cpp:

(WebCore::hardLinkOrCopyFile):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201794 r201796  
     12016-06-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GLIB] Implement hardLinkOrCopyFile() in FileSystemGlib
     4        https://bugs.webkit.org/show_bug.cgi?id=158473
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        It was added in r199230 to be used by IndexedDB blob support, but never implemented for GLib.
     9
     10        * platform/glib/FileSystemGlib.cpp:
     11        (WebCore::hardLinkOrCopyFile):
     12
    1132016-06-07  Adam Bergkvist  <adam.bergkvist@ericsson.com>
    214
  • trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp

    r200163 r201796  
    373373}
    374374
    375 bool hardLinkOrCopyFile(const String&, const String&)
    376 {
    377     // FIXME: Implement
    378     return false;
    379 }
    380 
    381 }
     375bool hardLinkOrCopyFile(const String& source, const String& destination)
     376{
     377#if OS(WINDOWS)
     378    return !!::CopyFile(source.charactersWithNullTermination().data(), destination.charactersWithNullTermination().data(), TRUE);
     379#else
     380    GUniquePtr<gchar> sourceFilename = unescapedFilename(source);
     381    if (!sourceFilename)
     382        return false;
     383
     384    GUniquePtr<gchar> destinationFilename = unescapedFilename(destination);
     385    if (!destinationFilename)
     386        return false;
     387
     388    if (!link(sourceFilename.get(), destinationFilename.get()))
     389        return true;
     390
     391    // Hard link failed. Perform a copy instead.
     392    GRefPtr<GFile> sourceFile = adoptGRef(g_file_new_for_path(sourceFilename.get()));
     393    GRefPtr<GFile> destinationFile = adoptGRef(g_file_new_for_path(destinationFilename.get()));
     394    return g_file_copy(sourceFile.get(), destinationFile.get(), G_FILE_COPY_NONE, nullptr, nullptr, nullptr, nullptr);
     395#endif
     396}
     397
     398}
Note: See TracChangeset for help on using the changeset viewer.