GadgetSeed  0.9.6
file_operation.c
[詳解]
1 /** @file
2  @brief ファイル操作
3 
4  @date 2017.05.02
5  @author Takashi SHUDO
6 */
7 
8 #include "str.h"
9 #include "shell.h"
10 #include "tprintf.h"
11 #include "file.h"
12 
13 
14 static const struct st_file_operation * const init_file_operation[] = {
15  0
16 };
17 
18 static const struct st_file_operation * const * p_file_operation = init_file_operation;
19 
20 void set_file_operation(const struct st_file_operation * const fileop[])
21 {
22  p_file_operation = fileop;
23 }
24 
25 #define EXT_LEN 12
26 
27 int do_file_operation(uchar *fname, uchar *arg)
28 {
29  int rt = 0;
30  uchar ext[EXT_LEN + 1] = {0};
31  const struct st_file_operation * const *fo = p_file_operation;
32 
33  (void)get_filename_extension(ext, fname, EXT_LEN);
34  (void)str2cap(ext);
35 
36  while(*fo) {
37  if(strcomp((uchar *)(*fo)->ext, ext) == 0) {
38  rt = (*fo)->operation(fname, arg);
39  }
40  fo ++;
41  }
42 
43  return rt;
44 }
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
Definition: str.h:13
コマンドシェル
文字列処理
ファイル
ファイル種別に対するコマンド実行定義
Definition: shell.h:22
int strcomp(const uchar *s1, const uchar *s2)
文字列比較
Definition: str.c:583
uchar ext[4]
拡張子文字列
Definition: shell.h:23
uchar * str2cap(uchar *str)
小文字から大文字へ変換
Definition: str.c:678
uchar * get_filename_extension(uchar *ext, const uchar *filename, unsigned int len)
ファイル拡張子を取得する
Definition: file.c:676
機能限定printf