X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ffile-handle-def.c;h=91300fed2b25df186fe74165a1a69dee517c9cb5;hb=21ed03889d193fbcc573d5999e8e16196f3313d0;hp=9c853e5e983d7968bf427e0a01765680c1cec0e0;hpb=a860739c34aad93afd7cb2cb24bcaef3e6eeae8a;p=pspp diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 9c853e5e98..91300fed2b 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -50,6 +50,8 @@ struct file_handle /* FH_REF_FILE only. */ char *file_name; /* File name as provided by user. */ + char *file_name_encoding; /* The character encoding of file_name, + This is NOT the encoding of the file contents! */ enum fh_mode mode; /* File mode. */ enum fh_line_ends line_ends; /* Line ends for text files. */ @@ -114,6 +116,7 @@ free_handle (struct file_handle *handle) free (handle->id); free (handle->name); free (handle->file_name); + free (handle->file_name_encoding); free (handle->encoding); free (handle); } @@ -227,7 +230,7 @@ fh_inline_file (void) existing file identifiers. The new handle is associated with file FILE_NAME and the given PROPERTIES. */ struct file_handle * -fh_create_file (const char *id, const char *file_name, +fh_create_file (const char *id, const char *file_name, const char *file_name_encoding, const struct fh_properties *properties) { char *handle_name; @@ -236,6 +239,7 @@ fh_create_file (const char *id, const char *file_name, handle_name = id != NULL ? xstrdup (id) : xasprintf ("`%s'", file_name); handle = create_handle (id, handle_name, FH_REF_FILE, properties->encoding); handle->file_name = xstrdup (file_name); + handle->file_name_encoding = file_name_encoding ? xstrdup (file_name_encoding) : NULL; handle->mode = properties->mode; handle->line_ends = properties->line_ends; handle->record_width = properties->record_width; @@ -314,6 +318,16 @@ fh_get_file_name (const struct file_handle *handle) return handle->file_name; } + +/* Returns the character encoding of the name of the file associated with HANDLE. */ +const char * +fh_get_file_name_encoding (const struct file_handle *handle) +{ + assert (handle->referent == FH_REF_FILE); + return handle->file_name_encoding; +} + + /* Returns the mode of HANDLE. */ enum fh_mode fh_get_mode (const struct file_handle *handle)