Don't try to read from /etc/mime.types if it

is not present/readable.

Don't process blank lines in mime.types

There wasn't an issue seen with this, just
cleaning up the code a bit.


git-svn-id: http://s3fs.googlecode.com/svn/trunk@245 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
mooredan@suncup.net 2010-11-22 18:28:07 +00:00
parent 7429227922
commit 4187f03089
2 changed files with 19 additions and 13 deletions

View File

@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(s3fs, 1.15)
AC_INIT(s3fs, 1.16)
AC_CANONICAL_SYSTEM

View File

@ -1532,19 +1532,25 @@ static void* s3fs_init(struct fuse_conn_info *conn) {
pthread_mutex_init(&stat_cache_lock, NULL);
//
string line;
ifstream passwd("/etc/mime.types");
while (getline(passwd, line)) {
if (line[0]=='#')
continue;
stringstream tmp(line);
string mimeType;
tmp >> mimeType;
while (tmp) {
string ext;
tmp >> ext;
if (ext.size() == 0)
ifstream MT("/etc/mime.types");
if (MT.good()) {
while (getline(MT, line)) {
if (line[0]=='#') {
continue;
mimeTypes[ext] = mimeType;
}
if (line.size() == 0) {
continue;
}
stringstream tmp(line);
string mimeType;
tmp >> mimeType;
while (tmp) {
string ext;
tmp >> ext;
if (ext.size() == 0)
continue;
mimeTypes[ext] = mimeType;
}
}
}
return 0;