4 * ROX-Filer, filer for the ROX desktop project
5 * By Thomas Leonard, <tal197@ecs.soton.ac.uk>.
8 /* type.c - code for dealing with filetypes */
18 #include "gui_support.h"
23 /* Static prototypes */
25 /* XXX: Just for testing... */
26 static MIME_type text_plain
= {"text/plain"};
32 char *basetype_name(FileItem
*item
)
34 if (item
->flags
& ITEM_FLAG_SYMLINK
)
36 else if (item
->flags
& ITEM_FLAG_MOUNT_POINT
)
38 else if (item
->flags
& ITEM_FLAG_APPDIR
)
41 switch (item
->base_type
)
47 case TYPE_CHAR_DEVICE
:
49 case TYPE_BLOCK_DEVICE
:
60 /* MIME-type guessing */
62 /* Returns a pointer to the MIME-type string, or NULL if we have
65 MIME_type
*type_from_path(char *path
)
70 /* Actions for types */
72 gboolean
type_open(char *path
, MIME_type
*type
)
74 char *argv
[] = {NULL
, path
, NULL
};
78 gboolean needs_free
= FALSE
;
80 type_path
= g_string_new(type
->name
);
81 g_string_append(type_path
, "/open");
82 open
= choices_find_path_load_shared(type_path
->str
, "MIME-types");
83 g_string_free(type_path
, TRUE
);
88 if (stat(open
, &info
))
90 report_error("ROX-Filer", g_strerror(errno
));
94 if (S_ISDIR(info
.st_mode
))
96 argv
[0] = g_strconcat(open
, "/AppRun");
103 report_error("ROX-Filer",
104 "Failed to fork() child process");