X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ffile-handle-def.c;h=32ca5c948782e11564e5ae604a391c1bfbba9984;hb=378ff5f35086629f4656c5e46934d1ec51ec00ca;hp=5ece4486989889f6537bcc4d37ba27a6fa55df98;hpb=2322678e8fddbbf158b01b2720db2636404bba3b;p=pspp diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 5ece448698..32ca5c9487 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -18,16 +18,19 @@ 02110-1301, USA. */ #include + #include "file-handle-def.h" -#include "message.h" + +#include #include #include #include -#include "alloc.h" -#include "compiler.h" -#include "filename.h" -#include "message.h" -#include "magic.h" + +#include +#include +#include +#include +#include "file-name.h" #include "variable.h" #include "scratch-handle.h" @@ -50,7 +53,7 @@ struct file_handle enum fh_referent referent; /* What the file handle refers to. */ /* FH_REF_FILE only. */ - char *filename; /* Filename as provided by user. */ + char *file_name; /* File name as provided by user. */ struct file_identity *identity; /* For checking file identity. */ enum fh_mode mode; /* File mode. */ @@ -100,7 +103,7 @@ free_handle (struct file_handle *handle) /* Free data. */ free (handle->name); - free (handle->filename); + free (handle->file_name); fn_free_identity (handle->identity); scratch_handle_destroy (handle->sh); free (handle); @@ -127,18 +130,18 @@ fh_from_name (const char *handle_name) return NULL; } -/* Returns the handle for the file named FILENAME, +/* Returns the handle for the file named FILE_NAME, or a null pointer if none exists. Different names for the same file (e.g. "x" and "./x") are considered equivalent. */ struct file_handle * -fh_from_filename (const char *filename) +fh_from_file_name (const char *file_name) { struct file_identity *identity; struct file_handle *iter; /* First check for a file with the same identity. */ - identity = fn_get_identity (filename); + identity = fn_get_identity (file_name); if (identity != NULL) { for (iter = file_handles; iter != NULL; iter = iter->next) @@ -156,7 +159,7 @@ fh_from_filename (const char *filename) /* Then check for a file with the same name. */ for (iter = file_handles; iter != NULL; iter = iter->next) if (!iter->deleted - && iter->referent == FH_REF_FILE && !strcmp (filename, iter->filename)) + && iter->referent == FH_REF_FILE && !strcmp (file_name, iter->file_name)) return iter; return NULL; @@ -194,16 +197,16 @@ fh_inline_file (void) /* Creates a new file handle named HANDLE_NAME, which must not be the name of an existing file handle. The new handle is - associated with file FILENAME and the given PROPERTIES. */ + associated with file FILE_NAME and the given PROPERTIES. */ struct file_handle * -fh_create_file (const char *handle_name, const char *filename, +fh_create_file (const char *handle_name, const char *file_name, const struct fh_properties *properties) { struct file_handle *handle; assert (fh_from_name (handle_name) == NULL); handle = create_handle (handle_name, FH_REF_FILE); - handle->filename = xstrdup (filename); - handle->identity = fn_get_identity (filename); + handle->file_name = xstrdup (file_name); + handle->identity = fn_get_identity (file_name); handle->mode = properties->mode; handle->record_width = properties->record_width; handle->tab_width = properties->tab_width; @@ -367,8 +370,8 @@ fh_is_open (const struct file_handle *handle) } /* Returns the identifier of file HANDLE. If HANDLE was created - by referring to a filename instead of a handle name, returns - the filename, enclosed in double quotes. Return value is + by referring to a file name instead of a handle name, returns + the file name, enclosed in double quotes. Return value is owned by the file handle. Useful for printing error messages about use of file handles. */ @@ -387,10 +390,10 @@ fh_get_referent (const struct file_handle *handle) /* Returns the name of the file associated with HANDLE. */ const char * -fh_get_filename (const struct file_handle *handle) +fh_get_file_name (const struct file_handle *handle) { assert (handle->referent == FH_REF_FILE); - return handle->filename; + return handle->file_name; } /* Returns the mode of HANDLE. */