D-Bus 1.14.10
Functions
DBusFile

Functions

dbus_bool_t _dbus_file_exists (const char *file)
 File interface. More...
 
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_file_get_contents (DBusString *str, const DBusString *filename, DBusError *error)
 Appends the contents of the given file to the string, returning error code. More...
 
dbus_bool_t _dbus_string_save_to_file (const DBusString *str, const DBusString *filename, dbus_bool_t world_readable, DBusError *error)
 Writes a string out to a file. More...
 
dbus_bool_t _dbus_make_file_world_readable (const DBusString *filename, DBusError *error)
 Makes the file readable by every user in the system. More...
 
dbus_bool_t _dbus_create_file_exclusively (const DBusString *filename, DBusError *error)
 Creates the given file, failing if the file already exists. More...
 
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_delete_file (const DBusString *filename, DBusError *error)
 Deletes the given file. More...
 

Detailed Description

Function Documentation

◆ _dbus_create_file_exclusively()

dbus_bool_t _dbus_create_file_exclusively ( const DBusString filename,
DBusError error 
)

Creates the given file, failing if the file already exists.

Parameters
filenamethe filename
errorerror location
Returns
TRUE if we created the file and it didn't exist

Definition at line 351 of file dbus-file-unix.c.

References _dbus_close(), DBUS_ERROR_FAILED, dbus_set_error(), FALSE, NULL, and TRUE.

◆ _dbus_delete_file()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_delete_file ( const DBusString filename,
DBusError error 
)

Deletes the given file.

Parameters
filenamethe filename
errorerror location
Returns
TRUE if unlink() succeeded

Definition at line 397 of file dbus-file-unix.c.

References _dbus_strerror_from_errno(), DBUS_ERROR_FAILED, dbus_set_error(), FALSE, and TRUE.

◆ _dbus_file_exists()

dbus_bool_t _dbus_file_exists ( const char *  file)

File interface.

File interface.

Parameters
filefull path to the file
Returns
TRUE if file exists

Definition at line 563 of file dbus-sysdeps-util-unix.c.

References FALSE, and TRUE.

Referenced by _dbus_user_at_console().

◆ _dbus_file_get_contents()

DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_file_get_contents ( DBusString str,
const DBusString filename,
DBusError error 
)

Appends the contents of the given file to the string, returning error code.

At the moment, won't open a file more than a megabyte in size.

Parameters
strthe string to append to
filenamefilename to load
errorplace to set an error
Returns
FALSE if error was set

Definition at line 55 of file dbus-file-unix.c.

References _dbus_close(), _dbus_error_from_errno(), _dbus_read(), _dbus_string_set_length(), DBUS_ERROR_FAILED, dbus_set_error(), FALSE, NULL, and TRUE.

◆ _dbus_make_file_world_readable()

dbus_bool_t _dbus_make_file_world_readable ( const DBusString filename,
DBusError error 
)

Makes the file readable by every user in the system.

Parameters
filenamethe filename
errorerror location
Returns
TRUE if the file's permissions could be changed.

Definition at line 324 of file dbus-file-unix.c.

References DBUS_ERROR_FAILED, dbus_set_error(), FALSE, and TRUE.

Referenced by _dbus_string_save_to_file().

◆ _dbus_string_save_to_file()

dbus_bool_t _dbus_string_save_to_file ( const DBusString str,
const DBusString filename,
dbus_bool_t  world_readable,
DBusError error 
)

Writes a string out to a file.

If the file exists, it will be atomically overwritten by the new data.

Parameters
strthe string to write out
filenamethe file to save string to
world_readableIf set, ensure the file is world readable
errorerror to be filled in on failure
Returns
FALSE on failure

If the file exists, it will be atomically overwritten by the new data.

Parameters
strthe string to write out
filenamethe file to save string to
world_readableif true, ensure file is world readable
errorerror to be filled in on failure
Returns
FALSE on failure

Definition at line 164 of file dbus-file-unix.c.

References _dbus_close(), _dbus_error_from_errno(), _dbus_generate_random_ascii(), _dbus_make_file_world_readable(), _dbus_string_append(), _dbus_string_copy(), _dbus_string_free(), _dbus_string_init(), _dbus_write(), DBUS_ERROR_NO_MEMORY, dbus_set_error(), FALSE, NULL, and TRUE.

Referenced by _dbus_write_uuid_file().