static int folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { int res; int from_card; int folder_nr; Camera *camera = data; char *dc120_folder_card = _("CompactFlash Card"); res = find_folder( camera, folder, &from_card, &folder_nr, context); if( res != (GP_OK) ) { return res; } if( !from_card && folder_nr==0 ) { gp_list_append(list, dc120_folder_card, NULL); return (dc120_get_albums(camera, from_card, list, context)); } else if( from_card && folder_nr==0 ) { return (dc120_get_albums(camera, from_card, list, context)); } else { return (GP_OK); } }
static int spfs_getattr(const char *path, struct stat *stbuf) { folder_t *folder; memset(stbuf, 0, sizeof(struct stat)); if(strcmp(path, "/") == 0) { stbuf->st_mode = S_IFDIR | 0555; stbuf->st_nlink = 2; return 0; } else { if((folder = find_folder(path + 1))) { stbuf->st_mode = S_IFDIR | 0555; stbuf->st_nlink = 2; return 0; } file_t *file; if((file = find_file(path + 1))) { stbuf->st_mode = S_IFREG | 0444; stbuf->st_nlink = 1; stbuf->st_size = MAX_FILE_SIZE; return 0; } } return -ENOENT; }
static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { int res; int from_card; int folder_nr; Camera *camera = data; res = find_folder( camera, folder, &from_card, &folder_nr, context); if( res != (GP_OK) ) { return res; } return dc120_get_filenames(camera, from_card, folder_nr, list, context); /* Save the order of the pics (wtf: no filename access on dc120???) */ }
static struct media_folder *find_folder(GSList *folders, const char *pattern) { GSList *l; for (l = folders; l; l = l->next) { struct media_folder *folder = l->data; if (g_str_equal(folder->item->name, pattern)) return folder; if (g_str_equal(folder->item->path, pattern)) return folder; folder = find_folder(folder->subfolders, pattern); if (folder != NULL) return folder; } return NULL; }
/// Putting this in an init func, since it relies on app.renderer being fully constructed for the /// GL_State proxy global to work (mostly related to creating a shader) void asdf_renderer_t::init() { ASSERT(!CheckGLError(), "Error before asdf_renderer_t::init()"); gl_state.bind(framebuffer); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, render_target.texture_id, 0); GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0}; glDrawBuffers(1, DrawBuffers); ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Error creating main app framebuffer"); glViewport(0,0,app.settings.resolution_width,app.settings.resolution_height); ASSERT(!CheckGLError(), ""); auto shader_path = find_folder("shaders"); screen_shader = Content.create_shader(shader_path, "passthrough", "textured", 330); const quad_vertex_t quad_verts[] = { quad_vertex_t{vec3(-0.5f, -0.5f, 0.0f)}, quad_vertex_t{vec3( 0.5f, -0.5f, 0.0f)}, quad_vertex_t{vec3(-0.5f, 0.5f, 0.0f)}, quad_vertex_t{vec3(-0.5f, 0.5f, 0.0f)}, quad_vertex_t{vec3( 0.5f, -0.5f, 0.0f)}, quad_vertex_t{vec3( 0.5f, 0.5f, 0.0f)} }; quad.draw_mode = GL_TRIANGLES; quad.vbo.usage = GL_STATIC_DRAW; quad.set_data(quad_verts, 6, screen_shader); gl_state.unbind_vao(); gl_state.unbind_vbo(); ASSERT(!CheckGLError(), "Error initializing renderer"); }
static int spfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { folder_t *folder; (void) offset; (void) fi; if(strcmp(path, "/") == 0) { filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); for(folder = folders; folder; folder = folder->next) { filler(buf, folder->name, NULL, 0); } } else { folder = find_folder(path + 1); if(folder) { filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); file_t *file; for(file = folder->files; file; file = file->next) { filler(buf, file->name, NULL, 0); } } else { return -ENOENT; } } return 0; }
static int camera_file_action (Camera *camera, int action, CameraFile *file, const char *folder, const char *filename, GPContext *context) { CameraList *files = NULL; const char* file_name; int file_nr; int i; char *dot; int picnum=0; int result = GP_OK; /* first find the file */ int from_card; int folder_nr; result = find_folder( camera, folder, &from_card, &folder_nr, context ); if( result != (GP_OK) ) { return result; } result = gp_list_new( &files ); if( result != GP_OK ) { goto fail; } result = dc120_get_filenames(camera, from_card, folder_nr, files, context); if( result != GP_OK ) { goto fail; } /* now we have the list, search for the file. */ file_nr = -1; for( i = 0; i<gp_list_count( files ); i++ ) { gp_list_get_name( files, i, &file_name ); if( strcmp( file_name, filename ) == 0 ) { file_nr = i; /* ok, we found it. */ break; } } gp_list_free( files ); if( file_nr == -1 ) { /* not found */ return GP_ERROR; } picnum = gp_filesystem_number(camera->fs, folder, filename, context); if (picnum < 0) return picnum; if (action == DC120_ACTION_PREVIEW) { /* FIXME: marcus, fix type */ dot = strrchr(filename, '.'); if( dot && strlen( dot )>3 ) { strcpy( dot+1, "ppm"); } } return (dc120_file_action(camera, action, from_card, folder_nr, picnum+1, file, context)); /* yes, after that it is to handle failures. */ fail: if (files) gp_list_free( files ); return result; }
static struct media_folder *media_player_find_folder(struct media_player *mp, const char *pattern) { return find_folder(mp->folders, pattern); }