diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-05-23 13:29:37 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-05-23 13:29:37 +0000 |
commit | a16586c9b795aabead419c97ab35871a0f9c3fc0 (patch) | |
tree | e08b34118fbc4078d22b9d00455822c5a61d6cdc /riscos/filetype.c | |
parent | b30fde8b21274e29d54b54a4177785add0f1017e (diff) | |
download | netsurf-a16586c9b795aabead419c97ab35871a0f9c3fc0.tar.gz netsurf-a16586c9b795aabead419c97ab35871a0f9c3fc0.tar.bz2 |
Use local filetype directly, if we're "downloading" a local file
svn path=/trunk/netsurf/; revision=4189
Diffstat (limited to 'riscos/filetype.c')
-rw-r--r-- | riscos/filetype.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/riscos/filetype.c b/riscos/filetype.c index 08df1ab3f..6a44efefc 100644 --- a/riscos/filetype.c +++ b/riscos/filetype.c @@ -308,3 +308,46 @@ int ro_content_filetype_from_type(content_type type) { } return 0; } + +/** + * Determine the type of a local file. + * + * \param unix_path Unix style path to file on disk + * \return File type + */ +bits ro_filetype_from_unix_path(const char *unix_path) +{ + unsigned int len = strlen(unix_path) + 100; + char *path = calloc(len, 1); + char *r, *slash; + os_error *error; + bits file_type; + + if (!path) { + LOG(("Insufficient memory for calloc")); + warn_user("NoMemory", 0); + return osfile_TYPE_DATA; + } + + /* convert path to RISC OS format and read file type */ + r = __riscosify(unix_path, 0, __RISCOSIFY_NO_SUFFIX, path, len, 0); + if (r == 0) { + LOG(("__riscosify failed")); + free(path); + return osfile_TYPE_DATA; + } + + error = xosfile_read_stamped_no_path(path, 0, 0, 0, 0, 0, + &file_type); + if (error) { + LOG(("xosfile_read_stamped_no_path failed: %s", + error->errmess)); + free(path); + return osfile_TYPE_DATA; + } + + free(path); + + return file_type; +} + |