eyBuildLib API Reference : eyBuildLib

ebfile

NAME

ebfile - eybuild file operation library

ROUTINES

trimpath( ) - remove useless or noneffective '.', '..' in given path
get_dirlen( ) - get the length of directory from given path
get_filename( ) - get filename from given path
get_extname( ) - get file extended name from given path
file_size( ) - get file size if file exist
file_exists( ) - test file exist or not
file_isdir( ) - test the file is a directory or not
file_isreg( ) - test the file is a regular file or not
file_ischar( ) - test the file is a character device or not
file_isblock( ) - test the file is a block device or not
file_isfifo( ) - test the file is a fifo or not
file_islink( ) - test the file is a symbolic link or not
file_readable( ) - test the file readable or not
file_writeable( ) - test the file writeable or not
file_executable( ) - test the file executable or not
file_atime( ) - get the last access time of the file
file_ctime( ) - get the create time of the file
file_mtime( ) - get the last modified time of the file

DESCRIPTION

eybuild file operation library

INCLUDE

ebfile.h


eyBuildLib : Routines

trimpath( )

NAME

trimpath( ) - remove useless or noneffective '.', '..' in given path

SYNOPSIS

char * trimpath
    (
    char * path               /* to tidy */
    )

DESCRIPTION

this routine is to remove useless or noneffective '.', '..' in given path.

 Index  | Raw Path                  | Result
--------|---------------------------|------------------
 1      | path                      | normalized path  
 2      | /foo//                    | /foo/  
 3      | /foo/./                   | /foo/  
 4      | /foo/../bar               | /bar  
 5      | /foo/../bar/              | /bar/  
 6      | /foo/../bar/../baz        | /baz  
 7      | //foo//./bar              | /foo/bar  
 8      | /../foo                   | /foo  
 9      | /foo/../bar/../../baz     | /baz
 10     | /.././../                 | /  
 11     | /..                       | /  
 12     | ../foo                    | ../foo
 13     | ./foo/.././bar            | ./bar
 14     | foo/../.././bar/          | ../bar/

NOTE

This routine will force convert \ to / and jump over disk driver in WIN32 system.

RETURNS

pointer to path

SEE ALSO

ebfile


eyBuildLib : Routines

get_dirlen( )

NAME

get_dirlen( ) - get the length of directory from given path

SYNOPSIS

int get_dirlen
    (
    const char * path
    )

DESCRIPTION

this routine is to get the length of directory, which includes the last / or \

 Index  | Raw Path                  | Result
--------|---------------------------|------------------
 1      | c:                        | 2 
 2      | c:\mydir\foo.c            | 9
 3      | /usr/foo.c                | 5
 4      | /usr/                     | 5
 5      | /                         | 1
 6      | .                         | 0

RETURNS

the length of directory(includes last / or \)

SEE ALSO

ebfile


eyBuildLib : Routines

get_filename( )

NAME

get_filename( ) - get filename from given path

SYNOPSIS

char * get_filename
    (
    const char * path
    )

DESCRIPTION

this routine return the next address of last / or \, or the start address if not found

 Index  | Raw Path                  | Result
--------|---------------------------|------------------
 1      | c:foo.c                   | foo.c
 2      | c:\bar.c                  | bar.c
 3      | /usr/foo                  | foo
 4      | bar                       | bar

RETURNS

pointer to filename

SEE ALSO

ebfile


eyBuildLib : Routines

get_extname( )

NAME

get_extname( ) - get file extended name from given path

SYNOPSIS

char * get_extname
    (
    const char * path
    )

DESCRIPTION

this routine returned file externed name, or pointer to end of path if not found.

 Index  | Raw Path                  | Result
--------|---------------------------|------------------
 1      | c:\foo.c                  | .c
 2      | /usr/foo.tar.gz           | .tar.gz
 3      | /usr/                     | 

RETURNS

pointer to extern filename(includes .), or ""

SEE ALSO

ebfile


eyBuildLib : Routines

file_size( )

NAME

file_size( ) - get file size if file exist

SYNOPSIS

long file_size
    (
    const char * filename
    )

DESCRIPTION

this routine return the size if the file exist

RETURNS

return the size if the file exist, otherwise return ERROR

SEE ALSO

ebfile


eyBuildLib : Routines

file_exists( )

NAME

file_exists( ) - test file exist or not

SYNOPSIS

BOOL file_exists
    (
    const char * filename
    )

DESCRIPTION

this routine is to test file exist or not

RETURNS

TRUE if file exist, otherwize FALSE

SEE ALSO

ebfile


eyBuildLib : Routines

file_isdir( )

NAME

file_isdir( ) - test the file is a directory or not

SYNOPSIS

int file_isdir
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file is a directory or not

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_isreg( )

NAME

file_isreg( ) - test the file is a regular file or not

SYNOPSIS

int file_isreg
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file is a regular file or not

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_ischar( )

NAME

file_ischar( ) - test the file is a character device or not

SYNOPSIS

int file_ischar
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file is a character device or not

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_isblock( )

NAME

file_isblock( ) - test the file is a block device or not

SYNOPSIS

int file_isblock
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file is a block device or not

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_isfifo( )

NAME

file_isfifo( ) - test the file is a fifo or not

SYNOPSIS

int file_isfifo
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file is a fifo or not

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_islink( )

NAME

file_islink( ) - test the file is a symbolic link or not

SYNOPSIS

int file_islink
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file is a symbolic link or not

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_readable( )

NAME

file_readable( ) - test the file readable or not

SYNOPSIS

int file_readable
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file readable or not. In POSIX OS, the second bit of returned value is to mark root readable or not.

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_writeable( )

NAME

file_writeable( ) - test the file writeable or not

SYNOPSIS

int file_writeable
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file writeable or not. In POSIX OS, the second bit of returned value, is to mark root writeable or not.

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_executable( )

NAME

file_executable( ) - test the file executable or not

SYNOPSIS

int file_executable
    (
    const char * filename
    )

DESCRIPTION

this routine is to test the file executable or not. In POSIX OS, the second bit of returned value is to mark root executable or not.

RETURNS

ret>0 if yes, ret==0 if not, otherwize ret<0 if file not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_atime( )

NAME

file_atime( ) - get the last access time of the file

SYNOPSIS

time_t file_atime
    (
    const char * filename
    )

DESCRIPTION

this routine is to get the last access time of the file

RETURNS

last access time, or ERROR if file is not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_ctime( )

NAME

file_ctime( ) - get the create time of the file

SYNOPSIS

time_t file_ctime
    (
    const char * filename
    )

DESCRIPTION

this routine is to get the create time of the file

RETURNS

the create time of the file, or ERROR if file is not exist

SEE ALSO

ebfile


eyBuildLib : Routines

file_mtime( )

NAME

file_mtime( ) - get the last modified time of the file

SYNOPSIS

time_t file_mtime
    (
    const char * filename
    )

DESCRIPTION

this routine is to get the last modified time of the file

RETURNS

last last modified time, ERROR if file not exist

SEE ALSO

ebfile