File utilities

File utilities

Functions

Types and Values

#define GO_F_OK
enum GODotDot
struct GOFilePermissions
#define GO_R_OK
#define GO_W_OK
#define GO_X_OK

Object Hierarchy

    GBoxed
    ╰── GOFilePermissions

Description

Functions

go_basename_from_uri ()

char *
go_basename_from_uri (const char *uri);

Decode the final path component. Returns as UTF-8 encoded suitable for display.

Parameters

uri

The uri

 

Returns

UTF-8 encoded basename.

[transfer full]


go_dirname_from_uri ()

char *
go_dirname_from_uri (const char *uri,
                     gboolean brief);

Decode the all but the final path component. Returns as UTF-8 encoded suitable for display.

Parameters

uri

target

 

brief

if TRUE, hide "file://" if present.

 

Returns

UTF-8 encoded directory part.

[transfer full]


go_file_access ()

gint
go_file_access (char const *uri,
                gint mode);

Checks access for uri .

Parameters

uri

a URI

 

mode

access mode (e.g., GO_R_OK)

 

Returns

0 on success, or -1 on error.


go_file_create ()

GsfOutput *
go_file_create (char const *uri,
                GError **err);

Creates a file or return an error. If the file already exists, it is replaced.

Parameters

uri

target uri

 

err

GError.

[out][optional][nullable]

Returns

GsfOutput for new file.

[transfer full]


go_file_get_date_accessed ()

time_t
go_file_get_date_accessed (char const *uri);

Returns the last access time of uri .

Parameters

uri

a URI

 

Returns

the last access time, or -1 on error.


go_file_get_date_changed ()

time_t
go_file_get_date_changed (char const *uri);

Returns the last status change time of uri .

Parameters

uri

a URI

 

Returns

the last status change time, or -1 on error.


go_file_get_date_modified ()

time_t
go_file_get_date_modified (char const *uri);

Returns the last modification time of uri .

Parameters

uri

a URI

 

Returns

the last modification time, or -1 on error.


go_file_get_group_name ()

gchar *
go_file_get_group_name (char const *uri);

Returns the group name of the owner of a URI.

Parameters

uri

a URI

 

Returns

the group name in UTF-8, or NULL on error.

[transfer full][nullable]


go_file_get_modtime ()

GDateTime *
go_file_get_modtime (char const *uri);

Determine the last modification time of uri .

Parameters

uri

The uri

 

Returns

the modification time of the file.

[transfer full][nullable]


go_file_get_owner_name ()

gchar *
go_file_get_owner_name (char const *uri);

Returns the real name of the owner of a URI.

Parameters

uri

a URI

 

Returns

the owner name in UTF-8, or NULL on error.

[transfer full][nullable]


go_file_open ()

GsfInput *
go_file_open (char const *uri,
              GError **err);

Try all available methods to open a file or return an error

Parameters

uri

target uri

 

err

GError.

[out][optional][nullable]

Returns

non-NULL on success.

[transfer full]


go_file_split_urls ()

GSList *
go_file_split_urls (char const *data);

Splits the chain into a list of URIs. Lines starting with '#' are ignored.

Parameters

data

a string filled with a list of URIs separated by new lines.

 

Returns

the URIs list.

[element-type utf8][transfer full]


go_filename_from_uri ()

char *
go_filename_from_uri (const char *uri);

Convert an escaped URI into a filename.

Parameters

uri

an escaped URI

 

Returns

the filename.

[transfer full]


go_filename_simplify ()

char *
go_filename_simplify (const char *filename,
                      GODotDot dotdot,
                      gboolean make_absolute);

Simplifies a filename.

Parameters

filename

a filename

 

dotdot

how to handle ".."

 

make_absolute

whether to make the path absolute

 

Returns

the simplified filename.

[transfer full]


go_filename_to_uri ()

char *
go_filename_to_uri (const char *filename);

Convert a filename into an escaped URI.

Parameters

filename

a filename

 

Returns

the escaped URI.

[transfer full]


go_get_file_permissions ()

GOFilePermissions *
go_get_file_permissions (char const *uri);

Returns the file permissions for uri .

Parameters

uri

a URI

 

Returns

the file permissions, or NULL on error.

[transfer full][nullable]


go_get_mime_type ()

gchar *
go_get_mime_type (gchar const *uri);

Parameters

uri

the uri.

 

Returns

the mime type for the file.

[transfer full]


go_get_mime_type_for_data ()

gchar *
go_get_mime_type_for_data (gconstpointer data,
                           int data_size);

Parameters

data

the data.

 

data_size

the data size

 

Returns

the mime type for the data.

[transfer full]


go_mime_type_get_description ()

gchar *
go_mime_type_get_description (gchar const *mime_type);

Parameters

mime_type

the mime type to describe.

 

Returns

the description for the mime type. If the description is not found, a copy of the mime type itself will be returned.

[transfer full]


go_set_file_permissions ()

void
go_set_file_permissions (char const *uri,
                         GOFilePermissions *file_permissions);

Sets the file permissions for uri .

Parameters

uri

a URI

 

file_permissions

the file permissions

 

go_shell_arg_to_uri ()

char *
go_shell_arg_to_uri (const char *arg);

Convert a shell argv entry (assumed already translated into filename encoding) to an escaped URI.

Parameters

arg

a shell argument in filename encoding

 

Returns

the escaped URI.

[transfer full]


go_shell_argv_to_glib_encoding ()

gchar const **
go_shell_argv_to_glib_encoding (gint argc,
                                gchar const **argv);

Transform arguments to UTF-8 when needed.

Parameters

argc

arguments number

 

argv

command line arguments

 

Returns

the arguments in UTF-8 locale.

[transfer none]


go_shell_argv_to_glib_encoding_free ()

void
go_shell_argv_to_glib_encoding_free (void);

Frees the memory allocated by go_shell_argv_to_glib_encoding().

Types and Values

GO_F_OK

#  define GO_F_OK F_OK

enum GODotDot

Members

GO_DOTDOT_SYNTACTIC

assume no symlinks.

 

GO_DOTDOT_TEST

check.

 

GO_DOTDOT_LEAVE

leave alone.

 

struct GOFilePermissions

struct GOFilePermissions {
	gboolean owner_read;
	gboolean owner_write;
	gboolean owner_execute;

	gboolean group_read;
	gboolean group_write;
	gboolean group_execute;

	gboolean others_read;
	gboolean others_write;
	gboolean others_execute;
};

Members

gboolean owner_read;

owner can read.

 

gboolean owner_write;

owner can write.

 

gboolean owner_execute;

owner can execute.

 

gboolean group_read;

group can read.

 

gboolean group_write;

group can write.

 

gboolean group_execute;

group can execute.

 

gboolean others_read;

everybody can read.

 

gboolean others_write;

everybody can write.

 

gboolean others_execute;

everybody can execute.

 

GO_R_OK

#  define GO_R_OK R_OK

GO_W_OK

#  define GO_W_OK W_OK

GO_X_OK

#  define GO_X_OK X_OK