|
|
typedef struct trashbin_struct trashbin_t | trashbin_t |
#include <libtra/libtra.h>
trashbin_t * trash_init (const char *dir)
| trash_init |
#include <libtra/libtra.h>
Initialize a trash bin. Must be done before using a trash bin. If NULL is passed as dir then the default directory will be used (this is the usual behavior).
Returns pointer to a trashbin on success, NULL on failure.
Parameters:
dir | String pointer to a directory to use as the trashbin or NULL to use default. |
void trash_free (trashbin_t *trash)
| trash_free |
#include <libtra/libtra.h>
Frees the resources associated with the trashbin. Trashbin is now invalid.
Returns void
Parameters:
trash | Trashbin to free. |
int trash_file (trashbin_t *bin, const char *filename)
| trash_file |
#include <libtra/libtra.h>
Moves a file into the trashcan.This trashes a file with filename - if filename is not absolute uses the cwd for the path.
Returns 0 on success, negative on failure.
Parameters:
bin | Trashbin to move filename into. |
filename | The filename to trash. |
int trash_restorefilename (trashbin_t *bin, const char *name)
| trash_restorefilename |
#include <libtra/libtra.h>
Unlike trashitem_restore this restore accepts a filename and will iterate thru the list looking for the most recent match to the filename (if not full filename it works from the current directory) and then restores this file.
Returns: 0 on sucess (ie file found and restore), negative on error.
Parameters:
bin | Trashbin to search. |
name | Filename to look for. |
int trash_empty (trashbin_t *bin)
| trash_empty |
#include <libtra/libtra.h>
Empties the trashbin of all the files it currently contains. Note: This will make all the files in the trashbin much harder to recover.
Returns: 0 on sucess, negative on error.
Parameters:
bin | Trashbin to empty |
typedef struct trashiterator_struct trashiterator_t | trashiterator_t |
#include <libtra/libtra.h>
typedef struct trashitem_struct trashitem_t | trashitem_t |
#include <libtra/libtra.h>
trashiterator_t * trash_iterator (trashbin_t *bin, int release_kids)
| trash_iterator |
#include <libtra/libtra.h>
Returns an iterator for use in cycling thru the trashitems. Must be freed with trash_freeiterator. release_kids if set to true means that the trashitem_t * that the iterator gives on trashiterator_next will not be released automatically on subsequent calls or on freeing the iterator. The must be released by calling trash_freeiterator.
Returns a pointer to a trashiterator_t or NULL on failure.
Parameters:
bin | The trash bin |
void trashiterator_free (trashiterator_t *iter)
| trashiterator_free |
#include <libtra/libtra.h>
trashitem_t * trashiterator_next (trashiterator_t *iter)
| trashiterator_next |
#include <libtra/libtra.h>
Gives the next trashitem in the trashcan.
Returns the a pointer to the next item or NULL on failure.
Parameters:
iter | A trashiterator used to iterate thru the trashcan. |
void trashitem_free (trashitem_t *item)
| trashitem_free |
#include <libtra/libtra.h>
Frees the memory associate with the trashitem item. Note: This makes any string returns be trashitem_get* invalid. If release_kids was set to true in the trash_iterator then this function should no be called to free its kids (they are freed automatically).
Returns: void
Parameters:
item | Pointer to a trashitem. |
int trashitem_restore (trashitem_t *item)
| trashitem_restore |
#include <libtra/libtra.h>
Restores the trashitem to its original location in the filesystem. After this workingfilename will not be valid and further operations on the file (ie restore an item twice) will cause an error.
Returns 0 on success, negative on error.
Parameters:
item | Pointer a to a trashitem. |
const char * trashitem_getworkingfilename (const trashitem_t *item)
| trashitem_getworkingfilename |
#include <libtra/libtra.h>
Returns a string giving the filename where a read-only copy of the delete file/directory etc. can be found - this can be used to preview the file or get the size of the file etc. The pointer to the string returned is only valid as long as the trashitem passed is valid.
Returns NULL on failure or pointer to string.
Parameters:
item | Pointer to a trashitem. |
time_t trashitem_getdatedeletion (const trashitem_t *item)
| trashitem_getdatedeletion |
#include <libtra/libtra.h>
Returns in time_t the date the file was deleted (moved to the trash bin.
Returns 0 on failure.
Parameters:
item | Pointer to a trashitem. |
const char * trashitem_getoriginalpath (const trashitem_t *item)
| trashitem_getoriginalpath |
#include <libtra/libtra.h>
Gives the full path not including the filename or trailing / where the deleted file used to reside on disk. The pointer to the string returns is valid only as long as the trashitem item is valid.
Returns NULL on failure or pointer to a string.
Parameters:
item | Pointer to a trash item. |
const char * trashitem_getoriginalfiletitle (const trashitem_t *item)
| trashitem_getoriginalfiletitle |
#include <libtra/libtra.h>
Gives the filetitle (filename with no path included) or where the deleted file used to reside on disk. Pointer to the string returned is valid only as long as the trashitem is valid.
Returns NULL on failure or pointer to a string.
Parameters:
item | Pointer to a trash item. |
mode_t trashitem_getoriginalmode (const trashitem_t *item)
| trashitem_getoriginalmode |
#include <libtra/libtra.h>
Used to query the original access mode of the file before it was trashed (files in the trashbin are set to readonly.
Returns the access mode or 0 on error.
Parameters:
item | Pointer to a trash item. |
int trashitem_removefromtrash (trashitem_t *item)
| trashitem_removefromtrash |
#include <libtra/libtra.h>
Removes this file from the trashbin (deletes it for good). Be careful when using this function as it means the file is now as irrecoverable as if it had been deleted with rm.
Returns 0 on success, negative on error.
Parameters:
item | Pointer to a trash item. |
void * _safe_alloc (size_t size, int line, const char *file)
| _safe_alloc |
#include <libtra/libtra_internal.h>
void _report_error (const char *err, int line, const char *file)
| _report_error |
#include <libtra/libtra_internal.h>
Helper function used my macro report_error the prints errors to stderr.
Returns void.
Parameters:
err | A string describing the error. |
line | Line number of error. |
file | Filename error occured in. |
int move_file (const char *oldname, const char *newname)
| move_file |
#include <libtra/libtra_internal.h>
Move the node (file, dir, symlink etc) from oldname to newname.
Returns 0 on success, negative on failure.
Parameters:
oldname | The name of the filename currently. |
newname | Filename to move it to. |
int set_readonly (const char *newname)
| set_readonly |
#include <libtra/libtra_internal.h>
void assert_trashvalid (trashbin_t *bin)
| assert_trashvalid |
#include <libtra/libtra_internal.h>
Used in debugging to assert as best a possible that the trashbin is valid.
Returns: void
Parameters:
bin | The trashbin to check. |
int createdb_entry (const char *dbname, trashitem_t *trashdata)
| createdb_entry |
#include <libtra/libtra_internal.h>
Create a database file at dbname containing all the important info about dbname before it is moved into db. Does not check the actual file just uses the trashdata.
Returns 0 on success, negative on error.
Parameters:
dbname | The filename of the file in which to store the xml data. |
trashdata | Contains info about the file which is saved. |
int readdb_entry (trashitem_t *trashdata, const char *dbfile)
| readdb_entry |
#include <libtra/libtra_internal.h>
Reads the data from the db filename db file into trashdata (allocating filetitle and filepath).
Returns: 0 on success, negative on error
Parameters:
trashdata | Must be a pointer to an already allocated trashdata_struct that will be filled with data. |
dbfile | A string giving the filename of the dbfile to open |
int gettitleandpath (const char *filename, char **filepath, char **filetitle)
| gettitleandpath |
#include <libtra/libtra_internal.h>
Get the filetitle and absolute filepath of the given filename - using the cwd if necessary and removing any double so that this is a unique filename.. Note: the pointers need to be freed when they are finished with.
Returns 0 on success, negative on error.
Parameters:
filename | Filename to make absolute and get filepath and filetitle from. |
filepath | Pointer to set to filepath. |
filetitle | Pointer to set to filetitle. |
char * getworkingfilename (char *dbname)
| getworkingfilename |
#include <libtra/libtra_internal.h>
This function takes the string filename of the db file and modifies it to point to a working copy of the trashed file. It then returns a pointer to this string. ie Passed "/home/test/.trash/db/asdf" and modifies string to "/home/test/.trash/asdf" and returns a pointer to this string.
Returns: Pointer to working copy of the trashed file or NULL on failure.
Parameters:
dbname | Pointer to a modifiable string of the db file. |
mode_t getmode (const char *filename)
| getmode |
#include <libtra/libtra_internal.h>
Helper function that does a lstat of filename and returns the current mode of the file.
Returns: The mode of the file.
Parameters:
filename | The filename to stat. |
int issymlink (const char *filename)
| issymlink |
#include <libtra/libtra_internal.h>
Checks by calling lstat to see what type of file this is to see if it is a symlink.
Returns: 0 if file is not a symlink otherwise 1.
Parameters:
filename | . The filename to test for being a symlink. |
Generated by: jjhunt on r2d2 on Mon Jan 12 14:10:43 2004, using kdoc 2.0a54. |