(_path_is_scheme): New
function. Implements auto-detection for the "path" scheme.
Showing
1 changed file
with
18 additions
and
1 deletions
... | @@ -73,6 +73,23 @@ static struct _record _file_record = | ... | @@ -73,6 +73,23 @@ static struct _record _file_record = |
73 | }; | 73 | }; |
74 | record_t file_record = &_file_record; | 74 | record_t file_record = &_file_record; |
75 | 75 | ||
76 | static int | ||
77 | _path_is_scheme (record_t record, const char *url) | ||
78 | { | ||
79 | if (url | ||
80 | && record->scheme | ||
81 | && strncasecmp (record->scheme, url, strlen (record->scheme)) == 0) | ||
82 | { | ||
83 | struct stat st; | ||
84 | |||
85 | if (stat (url, &st) < 0) | ||
86 | return 1; /* mailbox_open will complain */ | ||
87 | |||
88 | return S_ISREG (st.st_mode) || S_ISCHR (st.st_mode); | ||
89 | } | ||
90 | return 0; | ||
91 | } | ||
92 | |||
76 | static struct _record _path_record = | 93 | static struct _record _path_record = |
77 | { | 94 | { |
78 | MU_PATH_SCHEME, | 95 | MU_PATH_SCHEME, |
... | @@ -81,7 +98,7 @@ static struct _record _path_record = | ... | @@ -81,7 +98,7 @@ static struct _record _path_record = |
81 | NULL, /* Mailer init. */ | 98 | NULL, /* Mailer init. */ |
82 | _folder_mbox_init, /* Folder init. */ | 99 | _folder_mbox_init, /* Folder init. */ |
83 | NULL, /* No need for an owner. */ | 100 | NULL, /* No need for an owner. */ |
84 | NULL, /* is_scheme method. */ | 101 | _path_is_scheme, /* is_scheme method. */ |
85 | NULL, /* get_url method. */ | 102 | NULL, /* get_url method. */ |
86 | NULL, /* get_mailbox method. */ | 103 | NULL, /* get_mailbox method. */ |
87 | NULL, /* get_mailer method. */ | 104 | NULL, /* get_mailer method. */ | ... | ... |
-
Please register or sign in to post a comment