CuiFilename

Name

CuiFilename -- 

Synopsis


#include <history.h>


            CuiFilename;
CuiFilename* cui_filename_new               (const char *file,
                                             const char *directory);
gchar*      cui_filename_get_filename       (CuiFilename *file);
gchar*      cui_filename_get_canonical_filename
                                            (CuiFilename *file,
                                             gchar *working_directory);
gchar*      cui_filename_get_canonical_for_newname
                                            (CuiFilename *file,
                                             gchar *working_directory,
                                             gchar *newname);
void        cui_filename_set_mode_string    (CuiFilename *filename,
                                             const gchar *mode_string);
void        cui_filename_set_mode_string_owner
                                            (CuiFilename *filename,
                                             const gchar *string);
void        cui_filename_set_mode_string_group
                                            (CuiFilename *filename,
                                             const gchar *string);
void        cui_filename_set_mode_string_others
                                            (CuiFilename *filename,
                                             const gchar *string);
void        cui_filename_set_owner          (CuiFilename *filename,
                                             const gchar *owner);
gchar*      cui_filename_get_owner          (CuiFilename *file);
void        cui_filename_set_group          (CuiFilename *filename,
                                             const gchar *group);
gchar*      cui_filename_get_group          (CuiFilename *file);
void        cui_filename_set_owner_and_group
                                            (CuiFilename *filename,
                                             const gchar *owner,
                                             const gchar *group);
enum        CuiFileType;
gboolean    cui_filename_is_compressed      (CuiFilename *filename);
CuiFileType cui_filename_get_filetype       (CuiFilename *filename);
const gchar* cui_filename_get_typename      (CuiFilename *filename);
gboolean    cui_filename_is_dir             (CuiFilename *filename);
gboolean    cui_filename_is_block_device    (CuiFilename *filename);
gboolean    cui_filename_is_character_device
                                            (CuiFilename *filename);
gboolean    cui_filename_is_user_read       (CuiFilename *filename);
gboolean    cui_filename_is_user_write      (CuiFilename *filename);
gboolean    cui_filename_is_user_execute    (CuiFilename *filename);
gboolean    cui_filename_is_group_read      (CuiFilename *filename);
gboolean    cui_filename_is_group_write     (CuiFilename *filename);
gboolean    cui_filename_is_group_execute   (CuiFilename *filename);
gboolean    cui_filename_is_others_read     (CuiFilename *filename);
gboolean    cui_filename_is_others_write    (CuiFilename *filename);
gboolean    cui_filename_is_others_execute  (CuiFilename *filename);
void        cui_filename_set_filetype_dir   (CuiFilename *filename);
void        cui_filename_set_filetype_regular
                                            (CuiFilename *filename);
void        cui_filename_set_filetype_link  (CuiFilename *filename);
gchar*      cui_filename_get_editor         (CuiFilename *filename,
                                             gchar *long_name);
gchar*      cui_filename_get_viewer         (CuiFilename *filename,
                                             gchar *long_name);
gchar*      cui_filename_get_processor      (CuiFilename *filename,
                                             gchar *long_name);
CuiFileSizeChange cui_filename_get_size_change
                                            (CuiFilename *filename);
GType       cui_filename_get_type           (void);
void        cui_filename_set_file_size      (CuiFilename *filename,
                                             gint64 size);
void        cui_filename_set_filetype_block (CuiFilename *filename);

Object Hierarchy


  GObject
   +----CuiFilename

Properties


  "directory"            gchararray            : Read / Write
  "filename"             gchararray            : Read / Write
  "group"                gchararray            : Read / Write
  "inode-modified"       gpointer              : Read / Write
  "last-modified"        gpointer              : Read / Write
  "last-used"            gpointer              : Read / Write
  "mode-string"          gchararray            : Read / Write
  "owner"                gchararray            : Read / Write
  "size"                 gint64                : Read / Write

Description

Details

CuiFilename

typedef struct _CuiFilename CuiFilename;


cui_filename_new ()

CuiFilename* cui_filename_new               (const char *file,
                                             const char *directory);

Creates a new CuiFilename which holds infomation about files and directories.

The function will unquote the filename with the g_shell_unquote function of the G library.

file :

the basename of the file

directory :

the path of the directory holds this file

Returns :

a new CuiFilename object


cui_filename_get_filename ()

gchar*      cui_filename_get_filename       (CuiFilename *file);

Returns the basename of the file. The return value is a newly allocated memory should be freed by the caller.

file :

a CuiFilename

Returns :

the basename of this file


cui_filename_get_canonical_filename ()

gchar*      cui_filename_get_canonical_filename
                                            (CuiFilename *file,
                                             gchar *working_directory);

Returns the simplest usable name for the file. The return value is newly allocated should be freed by the caller.

file :

a CuiFilename

working_directory :

the current working directory

Returns :

the basename of this file


cui_filename_get_canonical_for_newname ()

gchar*      cui_filename_get_canonical_for_newname
                                            (CuiFilename *file,
                                             gchar *working_directory,
                                             gchar *newname);

Returns what will be the canonical name of the given file if we change its name to the new name. This file is used when generating commands like mv, shich must be used like this:

mv ~/directory/filename ~/directory/newfilename

The function returns a newly allocated string which should be freed.

file :

a CuiFilename:

working_directory :

the current working directory

newname :

the new name of the file

Returns :

the shortest usable new name for the file


cui_filename_set_mode_string ()

void        cui_filename_set_mode_string    (CuiFilename *filename,
                                             const gchar *mode_string);

Sets the mode bits stored for this file by disassembling the mode string. The mode string is looks like this: 'drwxr-----' as the ls program used to print when the -l option is in use.

filename :

a CuiFilename

mode_string :

the mode string (first column of the output of 'ls -l')


cui_filename_set_mode_string_owner ()

void        cui_filename_set_mode_string_owner
                                            (CuiFilename *filename,
                                             const gchar *string);

Sets the mode bits stored for this file by disassembling the mode string. This function will change the stored mode string if it is already set.

filename :

a CuiFilename

string :

the owner rights in the mode string (eg. "rwx")


cui_filename_set_mode_string_group ()

void        cui_filename_set_mode_string_group
                                            (CuiFilename *filename,
                                             const gchar *string);

Sets the mode bits stored for this file by disassembling the mode string. This function will change the stored mode string if it is already set.

filename :

a CuiFilename

string :

the group rights in the mode string (eg. "rwx")


cui_filename_set_mode_string_others ()

void        cui_filename_set_mode_string_others
                                            (CuiFilename *filename,
                                             const gchar *string);

Sets the mode bits stored for this file by disassembling the mode string. This function will change the stored mode string if it is already set.

filename :

a CuiFilename

string :

the others rights in the mode string (eg. "rwx")


cui_filename_set_owner ()

void        cui_filename_set_owner          (CuiFilename *filename,
                                             const gchar *owner);

Sets the file owner's name for the filename.

filename :

a CuiFilename

owner :

the user name of the owner


cui_filename_get_owner ()

gchar*      cui_filename_get_owner          (CuiFilename *file);

file :

a CuiFilename

Returns :

the name of the owner of this file


cui_filename_set_group ()

void        cui_filename_set_group          (CuiFilename *filename,
                                             const gchar *group);

Sets the group owner's name for the filename.

filename :

a CuiFilename

group :

the group name


cui_filename_get_group ()

gchar*      cui_filename_get_group          (CuiFilename *file);

file :

a CuiFilename

Returns :

the name of the group owner of this file


cui_filename_set_owner_and_group ()

void        cui_filename_set_owner_and_group
                                            (CuiFilename *filename,
                                             const gchar *owner,
                                             const gchar *group);

Sets the name of the file owner and group owner for the filename.

filename :

a CuiFilename

owner :

the user name of the owner

group :

the group name


enum CuiFileType

typedef enum {
	FILETYPE_UNKNOWN,
	FILETYPE_FILE,
	FILETYPE_DIRECTORY,
	FILETYPE_BLOCK,
	FILETYPE_CHAR,
	FILETYPE_FIFO,
	FILETYPE_LINK,
	FILETYPE_SOCKET
} CuiFileType;


cui_filename_is_compressed ()

gboolean    cui_filename_is_compressed      (CuiFilename *filename);

Returns TRUE if the file is a compressed file. We return FALSE for a tar archive (if not compressed) since the user may want to compress these files with some other program.

filename :

a CuiFilename

Returns :

TRUE if the file is compressed


cui_filename_get_filetype ()

CuiFileType cui_filename_get_filetype       (CuiFilename *filename);

Returns the type of the file (such as regular file, directory, block special file, etc.).

filename :

a Filename object pointer

Returns :

the type of the file


cui_filename_get_typename ()

const gchar* cui_filename_get_typename      (CuiFilename *filename);

Returns the type of the file as a string (such as "regular file", "directory", "block special file", etc.). The string should not modified oor freed.

filename :

a Filename object pointer

Returns :

the type of the file


cui_filename_is_dir ()

gboolean    cui_filename_is_dir             (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the given file is a directory type entry.


cui_filename_is_block_device ()

gboolean    cui_filename_is_block_device    (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the given file is a block device.


cui_filename_is_character_device ()

gboolean    cui_filename_is_character_device
                                            (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the given file is a character device.


cui_filename_is_user_read ()

gboolean    cui_filename_is_user_read       (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the user has the right to read the file.


cui_filename_is_user_write ()

gboolean    cui_filename_is_user_write      (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the user has the right to write the file.


cui_filename_is_user_execute ()

gboolean    cui_filename_is_user_execute    (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the user has the right to execute the file.


cui_filename_is_group_read ()

gboolean    cui_filename_is_group_read      (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the group has the right to read the file.


cui_filename_is_group_write ()

gboolean    cui_filename_is_group_write     (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the group has the right to write the file.


cui_filename_is_group_execute ()

gboolean    cui_filename_is_group_execute   (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the group has the right to execute the file.


cui_filename_is_others_read ()

gboolean    cui_filename_is_others_read     (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the others has the right to read the file.


cui_filename_is_others_write ()

gboolean    cui_filename_is_others_write    (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the others has the right to write the file.


cui_filename_is_others_execute ()

gboolean    cui_filename_is_others_execute  (CuiFilename *filename);

filename :

a CuiFilename

Returns :

TRUE if the others has the right to execute the file.


cui_filename_set_filetype_dir ()

void        cui_filename_set_filetype_dir   (CuiFilename *filename);

Sets the type of the filename to directory type entry.

filename :

a CuiFilename


cui_filename_set_filetype_regular ()

void        cui_filename_set_filetype_regular
                                            (CuiFilename *filename);

Sets the type of the filename to regular file.

filename :

a CuiFilename


cui_filename_set_filetype_link ()

void        cui_filename_set_filetype_link  (CuiFilename *filename);

Sets the type of the filename to soft link.

filename :

a CuiFilename


cui_filename_get_editor ()

gchar*      cui_filename_get_editor         (CuiFilename *filename,
                                             gchar *long_name);

Returns a command line string which can be used to open an editor (not a viewer) for the given file. The string is in a newly allocated memory area which must be freed with the g_free() function.

filename :

a CuiFilename

long_name :

the full name of file used in the command

Returns :

a command which will start up an editor program for this file


cui_filename_get_viewer ()

gchar*      cui_filename_get_viewer         (CuiFilename *filename,
                                             gchar *long_name);

Returns a command line string which can be used to open a viewer (not an editor) for the given file. The string is in a newly allocated memory area which must be freed with the g_free() function.

filename :

a CuiFilename

long_name :

the full name of file used in the command

Returns :

a command which will start up a viewer program for this file


cui_filename_get_processor ()

gchar*      cui_filename_get_processor      (CuiFilename *filename,
                                             gchar *long_name);

Returns a command line string which can be used to open a processor (not a viewer) for the given file. The string is in a newly allocated memory area which must be freed with the g_free() function.

filename :

a CuiFilename

long_name :

the full name of file used in the command

Returns :

a command which will start up a processor program for this file


cui_filename_get_size_change ()

CuiFileSizeChange cui_filename_get_size_change
                                            (CuiFilename *filename);

filename :

Returns :


cui_filename_get_type ()

GType       cui_filename_get_type           (void);

Returns :


cui_filename_set_file_size ()

void        cui_filename_set_file_size      (CuiFilename *filename,
                                             gint64 size);

filename :

size :


cui_filename_set_filetype_block ()

void        cui_filename_set_filetype_block (CuiFilename *filename);

Sets the type of the filename to block device type entry.

filename :

a CuiFilename

Properties

The "directory" property

  "directory"            gchararray            : Read / Write

The directory in which we found the file.

Default value: ""


The "filename" property

  "filename"             gchararray            : Read / Write

The basename of the file.

Default value: ""


The "group" property

  "group"                gchararray            : Read / Write

The name of the file group owner.

Default value: ""


The "inode-modified" property

  "inode-modified"       gpointer              : Read / Write

The time the file inode last used.


The "last-modified" property

  "last-modified"        gpointer              : Read / Write

The time the file last modified.


The "last-used" property

  "last-used"            gpointer              : Read / Write

The time the file last used.


The "mode-string" property

  "mode-string"          gchararray            : Read / Write

The mode string as the '-l' option of the 'ls' used to write.

Default value: ""


The "owner" property

  "owner"                gchararray            : Read / Write

The user name of the file owner.

Default value: ""


The "size" property

  "size"                 gint64                : Read / Write

File size in bytes.

Default value: -1