PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ftk_file_system_dummy.c

http://ftk.googlecode.com/
C | 138 lines | 84 code | 25 blank | 29 comment | 9 complexity | ed42557a7db2da391e324d247e4a8476 MD5 | raw file
  1/*
  2 * File: ftk_file_system_posix.c
  3 * Author: Li XianJing <xianjimli@hotmail.com>
  4 * Brief:  posix implemented file system adaptor.
  5 *
  6 * Copyright (c) 2009 - 2011  Li XianJing <xianjimli@hotmail.com>
  7 *
  8 * Licensed under the Academic Free License version 2.1
  9 *
 10 * This program is free software; you can redistribute it and/or modify
 11 * it under the terms of the GNU General Public License as published by
 12 * the Free Software Foundation; either version 2 of the License, or
 13 * (at your option) any later version.
 14 *
 15 * This program is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18 * GNU General Public License for more details.
 19 *
 20 * You should have received a copy of the GNU General Public License
 21 * along with this program; if not, write to the Free Software
 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 23 */
 24
 25/*
 26 * History:
 27 * ================================================================
 28 * 2011-04-19 Li XianJing <xianjimli@hotmail.com> created
 29 *
 30 */
 31
 32#include "ftk_util.h"
 33#include "ftk_file_system.h"
 34
 35Ret ftk_file_get_info(const char* file_name, FtkFileInfo* info)
 36{
 37	int ret = 0;
 38	struct stat st;
 39	return_val_if_fail(file_name != NULL && info != NULL, RET_FAIL);
 40
 41	if((ret = stat(file_name, &st)) == 0)
 42	{
 43		memset(info, 0x00, sizeof(FtkFileInfo));
 44
 45		info->uid  = st.st_uid;
 46		info->gid  = st.st_gid;
 47		info->mode = st.st_mode;
 48		info->size = st.st_size; 
 49		info->is_dir = 0;
 50		info->last_access = st.st_atime;
 51		info->last_modify = st.st_mtime;
 52		ftk_strncpy(info->name, file_name, FTK_MAX_PATH);
 53
 54		return RET_OK;
 55	}
 56
 57	return RET_FAIL;
 58}
 59
 60FtkFsHandle ftk_file_open(const char* file_name, const char* mode)
 61{
 62	return_val_if_fail(file_name != NULL && mode != NULL, NULL);
 63
 64	return fopen(file_name, mode);
 65}
 66
 67int  ftk_file_seek(FtkFsHandle file, size_t pos)
 68{
 69	return fseek(file, pos, SEEK_SET);
 70}
 71
 72int  ftk_file_read(FtkFsHandle file, void* buffer, size_t length)
 73{
 74	return fread(buffer, 1, length, file);
 75}
 76
 77int  ftk_file_write(FtkFsHandle file, const void* buffer, size_t length)
 78{
 79	return fwrite(buffer, 1, length, file);
 80}
 81
 82void ftk_file_close(FtkFsHandle file)
 83{
 84	return_if_fail(file != NULL);
 85
 86	fclose(file);
 87}
 88
 89
 90FtkFsHandle ftk_dir_open(const char* dir_name)
 91{
 92	return NULL;
 93}
 94
 95Ret  ftk_dir_read(FtkFsHandle dir, FtkFileInfo* info)
 96{
 97	return RET_FAIL;
 98}
 99
100void ftk_dir_close(FtkFsHandle dir)
101{
102	return;
103}
104
105Ret ftk_fs_get_cwd(char cwd[FTK_MAX_PATH+1])
106{
107	return RET_FAIL;
108}
109
110Ret ftk_fs_delete_dir(const char* dir)
111{
112	return RET_FAIL;
113}
114
115Ret ftk_fs_delete_file(const char* file_name)
116{
117	return RET_FAIL;
118}
119
120Ret ftk_fs_create_dir(const char* dir)
121{
122	return RET_FAIL;
123}
124
125Ret ftk_fs_change_dir(const char* dir)
126{
127	return RET_FAIL;
128}
129
130Ret ftk_fs_move(const char* dir_from, const char* dir_to)
131{
132	return RET_FAIL;
133}
134
135int ftk_fs_is_root(const char* path)
136{
137	return 0;
138}