Changeset 247477 in webkit
- Timestamp:
- Jul 16, 2019 1:09:52 AM (5 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r247465 r247477 1 2019-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 1 23 2019-07-15 Myles C. Maxfield <mmaxfield@apple.com> 2 24 -
trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp
r245186 r247477 167 167 bool getFileSize(PlatformFileHandle handle, long long& resultSize) 168 168 { 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)); 170 170 if (!info) 171 171 return false; 172 172 173 resultSize = g_file_info_get_size(info );173 resultSize = g_file_info_get_size(info.get()); 174 174 return true; 175 175 } … … 285 285 286 286 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)); 288 288 if (!fileInfo) 289 289 return false; … … 330 330 { 331 331 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)); 333 333 GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(tempPath.get())); 334 334 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); 336 336 if (!isHandleValid(handle)) 337 337 return String(); … … 346 346 347 347 GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(filename.data())); 348 G FileIOStream* ioStream = 0;348 GRefPtr<GFileIOStream> ioStream; 349 349 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)); 351 351 else if (mode == FileOpenMode::Write) { 352 352 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)); 354 354 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)); 356 356 } 357 357 358 return ioStream ;358 return ioStream.leakRef(); 359 359 } 360 360 … … 386 386 } 387 387 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)) 391 389 return -1; 392 }393 390 return g_seekable_tell(G_SEEKABLE(g_io_stream_get_input_stream(G_IO_STREAM(handle)))); 394 391 } … … 398 395 gsize bytesWritten; 399 396 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); 401 398 return bytesWritten; 402 399 } … … 407 404 do { 408 405 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()); 410 407 if (bytesRead >= 0) 411 408 return bytesRead;
Note: See TracChangeset
for help on using the changeset viewer.