From 5bb5e2667df7459c288c3484d3539376a74a7c68 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 5 Apr 2014 23:34:51 +0100 Subject: Change the scope of some variables picked up by cppcheck, minor reformatting --- amiga/filetype.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'amiga/filetype.c') diff --git a/amiga/filetype.c b/amiga/filetype.c index bcb6b7e87..2d55e1f8e 100644 --- a/amiga/filetype.c +++ b/amiga/filetype.c @@ -55,9 +55,7 @@ enum const char *fetch_filetype(const char *unix_path) { static char mimetype[50]; - STRPTR ttype = NULL; struct DiskObject *dobj = NULL; - BPTR lock = 0; struct DataType *dtn; BOOL found = FALSE; lwc_string *lwc_mimetype; @@ -66,8 +64,7 @@ const char *fetch_filetype(const char *unix_path) We'll just do a filename check here for quickness, although the first word ought to be checked against WB_DISKMAGIC really. */ - if(strncmp(unix_path + strlen(unix_path) - 5, ".info", 5) == 0) - { + if(strncmp(unix_path + strlen(unix_path) - 5, ".info", 5) == 0) { strcpy(mimetype,"image/x-amiga-icon"); found = TRUE; } @@ -76,32 +73,26 @@ const char *fetch_filetype(const char *unix_path) /* Secondly try getting a tooltype "MIMETYPE" and use that as the MIME type. Will fail over to default icons if the file doesn't have a real icon. */ - if(!found) - { + if(!found) { if(dobj = GetIconTags(unix_path,ICONGETA_FailIfUnavailable,FALSE, - TAG_DONE)) - { + TAG_DONE)) { + STRPTR ttype = NULL; ttype = FindToolType(dobj->do_ToolTypes, "MIMETYPE"); - if(ttype) - { + if(ttype) { strcpy(mimetype,ttype); found = TRUE; } - FreeDiskObject(dobj); } } /* If that didn't work, use the MIME file and DataTypes */ - if(!found) - { - if (lock = Lock (unix_path, ACCESS_READ)) - { - if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL)) - { - if(ami_mime_from_datatype(dtn, &lwc_mimetype, NULL)) - { + if(!found) { + BPTR lock; + if (lock = Lock (unix_path, ACCESS_READ)) { + if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL)) { + if(ami_mime_from_datatype(dtn, &lwc_mimetype, NULL)) { strcpy(mimetype, lwc_string_data(lwc_mimetype)); found = TRUE; ReleaseDataType(dtn); -- cgit v1.2.3