示例#1
0
int
_ex_file_is_viewable(char *file)
{
   char *ext;
   int i = 0;
   const char *mime = NULL;

   if (!(mime = efreet_mime_type_get(file)))
     {
	ext = strrchr(file, '.');
	if(!ext) return 0;

	for(i = 0; viewables[i]; i++)
	  {
	     if(!strcasecmp(ext, viewables[i]))
	       return 1;
	  }
	return 0;
     }

   for (i = 0; mimes[i]; i++)
     {
	if (!strcasecmp(mime, mimes[i]))
	  return 1;
     }

   return 0;
}
示例#2
0
EAPI Elm_Code_File *elm_code_file_open(Elm_Code *code, const char *path)
{
   Elm_Code_File *ret;
   Eina_File *file;
   Eina_File_Line *line;
   Eina_Iterator *it;
   unsigned int lastindex;

   ret = elm_code_file_new(code);
   file = eina_file_open(path, EINA_FALSE);
   ret->file = file;
   ret->mime = efreet_mime_type_get(path);
   lastindex = 1;

   ret->map = eina_file_map_all(file, EINA_FILE_POPULATE);
   it = eina_file_map_lines(file);
   EINA_ITERATOR_FOREACH(it, line)
     {
        Elm_Code_Line *ecl;

        if (lastindex == 1)
          ret->line_ending = _elm_code_line_ending_get(line->start + line->length);

        /* Working around the issue that eina_file_map_lines does not trigger an item for empty lines */
        /* This was fixed in 1.13.99 so once we depend on 1.14 minimum this can go */
        while (lastindex < line->index - 1)
          {
             ecl = _elm_code_file_line_blank_create(ret, ++lastindex, NULL);
             if (!ecl) continue;

             ret->lines = eina_list_append(ret->lines, ecl);
          }

        _elm_code_file_line_insert_data(ret, line->start, line->length, lastindex = line->index, EINA_TRUE, NULL);
     }
示例#3
0
int
_ex_file_is_jpg(char *file)
{
   const char *mime;

   if (!(mime = efreet_mime_type_get(file)))
     return 0;

   if (!strcasecmp(mime, "image/jpeg"))
     return 1;

   return 0;
}
示例#4
0
/**
 * @param uri: The URI to look up the mime type for
 * @return Returns the mime type for the given URI or NULL on error
 * @brief Retrives the mime type for the given URI or NULL on error
 */
const char *
ewl_io_manager_uri_mime_type_get(const char *uri)
{
        const char *mime = NULL;

        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET(uri, NULL);
#if BUILD_EFREET_SUPPORT
        mime = efreet_mime_type_get(uri);
#else
        mime = "application/octet-stream";
#endif

        DRETURN_PTR(mime, DLEVEL_STABLE);
}
示例#5
0
文件: ef_mime.c 项目: RomainNaour/efl
int
ef_mime_cb_get(void)
{
   const char *mime = NULL, *icon;
   int misses = 0, i = 0;
   struct
     {
        char *file;
        char *mime;
     } files[] = {
        {"test_type.desktop", "application/x-desktop"},
        {"entry.png", "image/png"},
        {"entry", "image/png"},
        {"sub", "inode/directory"},
        { }
     };
   double start;

   if (!efreet_mime_init())
     {
        printf("Could not init efreet\n");
        return 1;
     }

   for (i = 0; files[i].file; ++i)
     {
        mime = efreet_mime_type_get(ef_test_path_get(files[i].file));
        if (!mime)
          {
             printf("Got %s as null instead of %s\n", files[i].file, files[i].mime);
             misses ++;
          }
        else if (strcmp(mime, files[i].mime))
          {
             printf("Got %s as %s instead of %s\n", files[i].file, mime, files[i].mime);
             misses ++;
          }
        start = ecore_time_get();
        icon = efreet_mime_type_icon_get(files[i].mime, THEME, SIZE);
        printf("mime icon: %s %s %f\n", files[i].mime, icon, ecore_time_get() - start);
     }

   efreet_mime_shutdown();

   return !misses;
}