g_file_measure_disk_usage (
  GFile* file,
  GFileMeasureFlags flags,
  GCancellable* cancellable,
  GFileMeasureProgressCallback progress_callback,
  gpointer progress_data,
  guint64* disk_usage,
  guint64* num_dirs,
  guint64* num_files,
  GError** error


Recursively measures the disk usage of file.

This is essentially an analog of the ‘du’ command, but it also reports the number of directories and non-directory files encountered (including things like symbolic links).

By default, errors are only reported against the toplevel file itself. Errors found while recursing are silently ignored, unless G_FILE_MEASURE_REPORT_ANY_ERROR is given in flags.

The returned size, disk_usage, is in bytes and should be formatted with g_format_size() in order to get something reasonable for showing in a user interface.

progress_callback and progress_data can be given to request periodic progress updates while scanning. See the documentation for GFileMeasureProgressCallback for information about when and how the callback will be invoked.

Available since:2.38


flags GFileMeasureFlags


cancellable GCancellable

Optional GCancellable.

 The argument can be NULL.
 The data is owned by the caller of the function.
progress_callback GFileMeasureProgressCallback

A GFileMeasureProgressCallback.

 The argument can be NULL.
progress_data gpointer

User_data for progress_callback.

 The argument can be NULL.
disk_usage guint64*

The number of bytes of disk space used.

 The argument will be set by the function.
 The argument can be NULL.
num_dirs guint64*

The number of directories encountered.

 The argument will be set by the function.
 The argument can be NULL.
num_files guint64*

The number of non-directories encountered.

 The argument will be set by the function.
 The argument can be NULL.
error GError **
  The return location for a GError*, or NULL.

Return value

Returns: gboolean

TRUE if successful, with the out parameters set. FALSE otherwise, with error set.