~ubuntu-branches/ubuntu/breezy/malaga/breezy

« back to all changes in this revision

Viewing changes to files.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2005-01-10 11:52:04 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110115204-hpgncw5pb0m1t8i6
Tags: 6.13-5
debian/control (malaga-doc Recommends): Suggest gv as a
postscript-viewer instead of ghostview.  (Closes: #289701).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 1995 Bjoern Beutel. */
 
2
 
 
3
/* Description. =============================================================*/
 
4
 
 
5
/* Operations for files and file names. */
 
6
 
 
7
/* File operations. =========================================================*/
 
8
 
 
9
extern bool_t file_exists( string_t file_name );
 
10
/* Return TRUE iff file FILE_NAME exists. */
 
11
 
 
12
extern FILE *open_stream( string_t file_name, string_t stream_mode );
 
13
/* Open file FILE_NAME and create a stream from/to it in mode STREAM_MODE.
 
14
 * Works like "fopen", but calls "error" if it doesn't work. */
 
15
 
 
16
extern void close_stream( FILE **stream_p, string_t file_name );
 
17
/* Close the stream *STREAM_P which is connected to the file FILE_NAME
 
18
 * and set *STREAM_P to NULL. Don't do anything if *STREAM_P == NULL.
 
19
 * Works like "fclose", but calls "error" if FILE_NAME != NULL and an error
 
20
 * occurs during closing. */
 
21
 
 
22
extern void write_vector( void *address, 
 
23
                          int_t item_size, 
 
24
                          int_t item_count, 
 
25
                          FILE *stream, 
 
26
                          string_t file_name );
 
27
/* Write ITEM_COUNT items, of size ITEM_SIZE each, stored at *ADDRESS,
 
28
 * to STREAM, which is connected to file FILE_NAME.
 
29
 * Works like "fwrite", but calls "error" if it doesn't work. */
 
30
 
 
31
extern void read_vector( void *address, 
 
32
                         int_t item_size, 
 
33
                         int_t item_count, 
 
34
                         FILE *stream, 
 
35
                         string_t file_name );
 
36
/* Read ITEM_COUNT items, of size ITEM_SIZE each, from STREAM,
 
37
 * which is connected to file FILE_NAME, and store them at *ADDRESS.
 
38
 * Works like "fread", but calls "error" if it doesn't work. */
 
39
 
 
40
extern void *read_new_vector( int_t item_size, 
 
41
                              int_t item_count, 
 
42
                              FILE *stream, 
 
43
                              string_t file_name );
 
44
/* Read ITEM_COUNT items, of size ITEM_SIZE each, from STREAM,
 
45
 * which is connected to file FILE_NAME, into allocated memory block,
 
46
 * and return a pointer to that block. */
 
47
 
 
48
extern void map_file( string_t file_name, void **address, int_t *length );
 
49
/* Map file "file_name" into the memory. It will be available in the 
 
50
 * memory region starting at *ADDRESS and will occupy LENGTH bytes.
 
51
 * After usage, return the memory region via "unmap_file". */
 
52
 
 
53
extern void unmap_file( void **address, int_t length );
 
54
/* Return the memory region that has been allocated by "map_file".
 
55
 * The region starts at *ADDRESS and occupies LENGTH bytes. */
 
56
 
 
57
/* File name operations. ====================================================*/
 
58
 
 
59
extern string_t name_in_path( string_t path_name );
 
60
/* Return the file name in PATH_NAME, i.e. the name after the last "/". */
 
61
 
 
62
extern string_t replace_vars_in_string( string_t string );
 
63
/* Replace environment variables of form "$(X)" in STRING.
 
64
 * Return the resulting string. It must be freed after use. */
 
65
 
 
66
extern string_t absolute_path( string_t src_path, string_t relative_to );
 
67
/* Return the absolute path name which is equivalent to SRC_PATH.
 
68
 * If SRC_PATH starts with "~", it's replaced by the home directory of the
 
69
 * user whose login name is following (current user if no login name).
 
70
 * If RELATIVE_TO is not NULL, SRC_NAME is relative to that path name.
 
71
 * RELATIVE_TO must be an absolute path name (a directory or a file).
 
72
 * The returned path must be freed after use. */
 
73
 
 
74
extern bool_t has_extension( string_t file_name, string_t extension );
 
75
/* Test if FILE_NAME has extension EXTENSION. */
 
76
 
 
77
extern string_t replace_extension( string_t file_name, string_t extension );
 
78
/* Return a new string that contains FILE_NAME with new EXTENSION. 
 
79
 * The string must be freed after use. */
 
80
 
 
81
extern void set_file_name( string_t *file_name_p, string_t file_name );
 
82
/* Set *FILE_NAME_P to FILE_NAME, converted to absolute path.
 
83
 * Print an error if *FILE_NAME_P is already set.
 
84
 * The created file name must be freed after use. */
 
85
 
 
86
extern void set_binary_file_name( string_t *file_name_p, string_t file_name );
 
87
/* Set *FILE_NAME_P to
 
88
 * FILE_NAME plus "_l" for little endian, "_b" for big endian, "_c" else,
 
89
 * converted to absolute path. 
 
90
 * Print an error if *FILE_NAME_P is already set.
 
91
 * The created file name must be freed after use. */
 
92
 
 
93
/* End of file. =============================================================*/