Changeset 238782 in webkit


Ignore:
Timestamp:
Dec 1, 2018 11:34:44 AM (5 years ago)
Author:
chris.reid@sony.com
Message:

Add generic implementations to FileSystemPOSIX.cpp
https://bugs.webkit.org/show_bug.cgi?id=192263

Reviewed by Yusuke Suzuki.

No new tests, no change in behavior.

Add generic FileSystemPOSIX implementations for:

  • stringFromFileSystemRepresentation
  • fileSystemRepresentation
  • moveFile
  • getVolumeFreeSpace

Also removing an unneeded PLATFORM(GTK) check since GTK is only using FileSystemGlib

  • platform/posix/FileSystemPOSIX.cpp:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238781 r238782  
     12018-12-01  Christopher Reid  <chris.reid@sony.com>
     2
     3        Add generic implementations to FileSystemPOSIX.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=192263
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        No new tests, no change in behavior.
     9
     10        Add generic FileSystemPOSIX implementations for:
     11            - stringFromFileSystemRepresentation
     12            - fileSystemRepresentation
     13            - moveFile
     14            - getVolumeFreeSpace
     15
     16        Also removing an unneeded PLATFORM(GTK) check since GTK is only using FileSystemGlib
     17
     18        * platform/posix/FileSystemPOSIX.cpp:
     19
    1202018-12-01  Zalan Bujtas  <zalan@apple.com>
    221
  • trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp

    r233487 r238782  
    3838#include <stdio.h>
    3939#include <sys/stat.h>
     40#include <sys/statvfs.h>
    4041#include <sys/types.h>
    4142#include <unistd.h>
     
    382383}
    383384
    384 #if !OS(DARWIN) || PLATFORM(GTK)
     385#if !PLATFORM(COCOA)
     386String stringFromFileSystemRepresentation(const char* path)
     387{
     388    if (!path)
     389        return String();
     390
     391    return String::fromUTF8(path);
     392}
     393
     394CString fileSystemRepresentation(const String& path)
     395{
     396    return path.utf8();
     397}
     398
     399bool moveFile(const String& oldPath, const String& newPath)
     400{
     401    auto oldFilename = fileSystemRepresentation(oldPath);
     402    if (oldFilename.isNull())
     403        return false;
     404
     405    auto newFilename = fileSystemRepresentation(newPath);
     406    if (newFilename.isNull())
     407        return false;
     408
     409    return rename(oldFilename.data(), newFilename.data()) != -1;
     410}
     411
     412bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace)
     413{
     414    struct statvfs fileSystemStat;
     415    if (statvfs(fileSystemRepresentation(path).data(), &fileSystemStat)) {
     416        freeSpace = fileSystemStat.f_bavail * fileSystemStat.f_frsize;
     417        return true;
     418    }
     419    return false;
     420}
     421#endif
     422
     423#if !OS(DARWIN)
    385424String openTemporaryFile(const String& prefix, PlatformFileHandle& handle)
    386425{
Note: See TracChangeset for help on using the changeset viewer.