Changeset 247477 in webkit


Ignore:
Timestamp:
Jul 16, 2019 1:09:52 AM (5 years ago)
Author:
Michael Catanzaro
Message:

[WPE][GTK] Improvements and fixes in FileSystemGlib.cpp
https://bugs.webkit.org/show_bug.cgi?id=199800

Reviewed by Carlos Garcia Campos.

Use nullptr.

Fix a GFileInfo leak in getFileSize.

Use GRefPtr to clarify ownership of the GFileIOStream in openFile.

  • wtf/glib/FileSystemGlib.cpp:

(WTF::FileSystemImpl::getFileSize):
(WTF::FileSystemImpl::getVolumeFreeSpace):
(WTF::FileSystemImpl::openTemporaryFile):
(WTF::FileSystemImpl::openFile):
(WTF::FileSystemImpl::seekFile):
(WTF::FileSystemImpl::writeToFile):
(WTF::FileSystemImpl::readFromFile):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r247465 r247477  
     12019-07-16  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [WPE][GTK] Improvements and fixes in FileSystemGlib.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=199800
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Use nullptr.
     9
     10        Fix a GFileInfo leak in getFileSize.
     11
     12        Use GRefPtr to clarify ownership of the GFileIOStream in openFile.
     13
     14        * wtf/glib/FileSystemGlib.cpp:
     15        (WTF::FileSystemImpl::getFileSize):
     16        (WTF::FileSystemImpl::getVolumeFreeSpace):
     17        (WTF::FileSystemImpl::openTemporaryFile):
     18        (WTF::FileSystemImpl::openFile):
     19        (WTF::FileSystemImpl::seekFile):
     20        (WTF::FileSystemImpl::writeToFile):
     21        (WTF::FileSystemImpl::readFromFile):
     22
    1232019-07-15  Myles C. Maxfield  <mmaxfield@apple.com>
    224
  • trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp

    r245186 r247477  
    167167bool getFileSize(PlatformFileHandle handle, long long& resultSize)
    168168{
    169     auto info = g_file_io_stream_query_info(handle, G_FILE_ATTRIBUTE_STANDARD_SIZE, nullptr, nullptr);
     169    GRefPtr<GFileInfo> info = adoptGRef(g_file_io_stream_query_info(handle, G_FILE_ATTRIBUTE_STANDARD_SIZE, nullptr, nullptr));
    170170    if (!info)
    171171        return false;
    172172
    173     resultSize = g_file_info_get_size(info);
     173    resultSize = g_file_info_get_size(info.get());
    174174    return true;
    175175}
     
    285285
    286286    GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(filename.data()));
    287     GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_filesystem_info(file.get(), G_FILE_ATTRIBUTE_FILESYSTEM_FREE, 0, 0));
     287    GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_filesystem_info(file.get(), G_FILE_ATTRIBUTE_FILESYSTEM_FREE, nullptr, nullptr));
    288288    if (!fileInfo)
    289289        return false;
     
    330330{
    331331    GUniquePtr<gchar> filename(g_strdup_printf("%s%s", prefix.utf8().data(), createCanonicalUUIDString().utf8().data()));
    332     GUniquePtr<gchar> tempPath(g_build_filename(g_get_tmp_dir(), filename.get(), NULL));
     332    GUniquePtr<gchar> tempPath(g_build_filename(g_get_tmp_dir(), filename.get(), nullptr));
    333333    GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(tempPath.get()));
    334334
    335     handle = g_file_create_readwrite(file.get(), G_FILE_CREATE_NONE, 0, 0);
     335    handle = g_file_create_readwrite(file.get(), G_FILE_CREATE_NONE, nullptr, nullptr);
    336336    if (!isHandleValid(handle))
    337337        return String();
     
    346346
    347347    GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(filename.data()));
    348     GFileIOStream* ioStream = 0;
     348    GRefPtr<GFileIOStream> ioStream;
    349349    if (mode == FileOpenMode::Read)
    350         ioStream = g_file_open_readwrite(file.get(), 0, 0);
     350        ioStream = adoptGRef(g_file_open_readwrite(file.get(), nullptr, nullptr));
    351351    else if (mode == FileOpenMode::Write) {
    352352        if (g_file_test(filename.data(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)))
    353             ioStream = g_file_open_readwrite(file.get(), 0, 0);
     353            ioStream = adoptGRef(g_file_open_readwrite(file.get(), nullptr, nullptr));
    354354        else
    355             ioStream = g_file_create_readwrite(file.get(), G_FILE_CREATE_NONE, 0, 0);
     355            ioStream = adoptGRef(g_file_create_readwrite(file.get(), G_FILE_CREATE_NONE, nullptr, nullptr));
    356356    }
    357357
    358     return ioStream;
     358    return ioStream.leakRef();
    359359}
    360360
     
    386386    }
    387387
    388     if (!g_seekable_seek(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))),
    389         offset, seekType, 0, 0))
    390     {
     388    if (!g_seekable_seek(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))), offset, seekType, nullptr, nullptr))
    391389        return -1;
    392     }
    393390    return g_seekable_tell(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle))));
    394391}
     
    398395    gsize bytesWritten;
    399396    g_output_stream_write_all(g_io_stream_get_output_stream(G_IO_STREAM(handle)),
    400         data, length, &bytesWritten, 0, 0);
     397        data, length, &bytesWritten, nullptr, nullptr);
    401398    return bytesWritten;
    402399}
     
    407404    do {
    408405        gssize bytesRead = g_input_stream_read(g_io_stream_get_input_stream(G_IO_STREAM(handle)),
    409             data, length, 0, &error.outPtr());
     406            data, length, nullptr, &error.outPtr());
    410407        if (bytesRead >= 0)
    411408            return bytesRead;
Note: See TracChangeset for help on using the changeset viewer.