ReactOS  0.4.14-dev-552-g2fad488
file.h File Reference
#include "msdos_fs.h"
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _fptr
 

Typedefs

typedef struct _fptr FDSC
 

Enumerations

enum  FD_TYPE { fdt_none, fdt_drop, fdt_undelete }
 

Functions

charfile_name (unsigned char *fixed)
 
int file_cvt (unsigned char *name, unsigned char *fixed)
 
void file_add (char *path, FD_TYPE type)
 
FDSC ** file_cd (FDSC **curr, char *fixed)
 
FD_TYPE file_type (FDSC **curr, char *fixed)
 
void file_modify (FDSC **curr, char *fixed)
 
void file_unused (void)
 

Variables

FDSCfp_root
 

Typedef Documentation

◆ FDSC

typedef struct _fptr FDSC

Enumeration Type Documentation

◆ FD_TYPE

Enumerator
fdt_none 
fdt_drop 
fdt_undelete 

Definition at line 28 of file file.h.

Definition: file.h:28
FD_TYPE
Definition: file.h:28
Definition: file.h:28

Function Documentation

◆ file_add()

void file_add ( char path,
FD_TYPE  type 
)

Definition at line 142 of file file.c.

143 {
144  FDSC **current, *walk;
145  char name[MSDOS_NAME];
146  char *here;
147 
148  current = &fp_root;
149  if (*path != '/')
150  die("%s: Absolute path required.", path);
151  path++;
152  while (1) {
153  if ((here = strchr(path, '/')))
154  *here = 0;
155  if (!file_cvt((unsigned char *)path, (unsigned char *)name))
156  exit(2);
157  for (walk = *current; walk; walk = walk->next)
158  if (!here && (!strncmp(name, walk->name, MSDOS_NAME) || (type ==
160  &&
161  !strncmp
162  (name + 1,
163  walk->name
164  + 1,
165  MSDOS_NAME
166  - 1))))
167  die("Ambiguous name: \"%s\"", path);
168  else if (here && !strncmp(name, walk->name, MSDOS_NAME))
169  break;
170  if (!walk) {
171  walk = alloc(sizeof(FDSC));
172  strncpy(walk->name, name, MSDOS_NAME);
173  walk->type = here ? fdt_none : type;
174  walk->first = NULL;
175  walk->next = *current;
176  *current = walk;
177  }
178  current = &walk->first;
179  if (!here)
180  break;
181  *here = '/';
182  path = here + 1;
183  }
184 }
FD_TYPE type
Definition: file.h:32
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct _fptr * first
Definition: file.h:33
FDSC * fp_root
Definition: file.c:32
char name[MSDOS_NAME]
Definition: file.h:31
smooth NULL
Definition: ftsmooth.c:416
Definition: file.h:28
#define MSDOS_NAME
Definition: msdos_fs.h:46
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
struct _fptr * next
Definition: file.h:34
#define alloc
Definition: rosglue.h:13
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: name.c:38
#define die(str)
Definition: mkdosfs.c:347
void exit(int exitcode)
Definition: _exit.c:33
Definition: file.h:30
int file_cvt(unsigned char *name, unsigned char *fixed)
Definition: file.c:84
struct task_struct * current
Definition: linux.c:32

◆ file_cd()

FDSC** file_cd ( FDSC **  curr,
char fixed 
)

Definition at line 186 of file file.c.

187 {
188  FDSC **walk;
189 
190  if (!curr || !*curr)
191  return NULL;
192  for (walk = curr; *walk; walk = &(*walk)->next)
193  if (!strncmp((*walk)->name, fixed, MSDOS_NAME) && (*walk)->first)
194  return &(*walk)->first;
195  return NULL;
196 }
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
smooth NULL
Definition: ftsmooth.c:416
#define MSDOS_NAME
Definition: msdos_fs.h:46
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
struct _fptr * next
Definition: file.h:34
Definition: file.h:30

Referenced by subdirs().

◆ file_cvt()

int file_cvt ( unsigned char name,
unsigned char fixed 
)

Definition at line 84 of file file.c.

85 {
86  unsigned char c;
87  int size, ext, cnt;
88 
89  size = 8;
90  ext = 0;
91  while (*name) {
92  c = *name;
93  if (c < ' ' || c > 0x7e || strchr("*?<>|\"/", c)) {
94  printf("Invalid character in name. Use \\ooo for special "
95  "characters.\n");
96  return 0;
97  }
98  if (c == '.') {
99  if (ext) {
100  printf("Duplicate dots in name.\n");
101  return 0;
102  }
103  while (size--)
104  *fixed++ = ' ';
105  size = 3;
106  ext = 1;
107  name++;
108  continue;
109  }
110  if (c == '\\') {
111  c = 0;
112  name++;
113  for (cnt = 3; cnt; cnt--) {
114  if (*name < '0' || *name > '7') {
115  printf("Expected three octal digits.\n");
116  return 0;
117  }
118  c = c * 8 + *name++ - '0';
119  }
120  name--;
121  }
122  if (islower(c))
123  c = toupper(c);
124  if (size) {
125  *fixed++ = c;
126  size--;
127  }
128  name++;
129  }
130  if (*name || size == 8)
131  return 0;
132  if (!ext) {
133  while (size--)
134  *fixed++ = ' ';
135  size = 3;
136  }
137  while (size--)
138  *fixed++ = ' ';
139  return 1;
140 }
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
char ext[3]
Definition: mkdosfs.c:358
int toupper(int c)
Definition: utclib.c:881
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
#define islower(c)
Definition: acclib.h:72
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: name.c:38
#define c
Definition: ke_i.h:80
#define printf
Definition: config.h:203
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by file_add(), and rename_file().

◆ file_modify()

void file_modify ( FDSC **  curr,
char fixed 
)

Definition at line 230 of file file.c.

231 {
232  FDSC **this, *next;
233 
234  if (!(this = file_find(curr, fixed)))
235  die("Internal error: file_find failed");
236  switch ((*this)->type) {
237  case fdt_drop:
238  printf("Dropping %s\n", file_name((unsigned char *)fixed));
239  *(unsigned char *)fixed = DELETED_FLAG;
240  break;
241  case fdt_undelete:
242  *fixed = *(*this)->name;
243  printf("Undeleting %s\n", file_name((unsigned char *)fixed));
244  break;
245  default:
246  die("Internal error: file_modify");
247  }
248  next = (*this)->next;
249  free(*this);
250  *this = next;
251 }
#define DELETED_FLAG
Definition: msdos_fs.h:43
static FDSC ** file_find(FDSC **dir, char *fixed)
Definition: file.c:198
char * file_name(unsigned char *fixed)
Definition: file.c:58
Definition: file.h:28
#define free
Definition: debug_ros.c:5
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
static unsigned __int64 next
Definition: rand_nt.c:6
#define die(str)
Definition: mkdosfs.c:347
Definition: file.h:30
#define printf
Definition: config.h:203

Referenced by add_file().

◆ file_name()

char* file_name ( unsigned char fixed)

Construct the "pretty-printed" representation of the name in a short directory entry.

Parameters
[in]fixedPointer to name[0] of a DIR_ENT
Returns
Pointer to static string containing pretty "8.3" equivalent of the name in the directory entry.

Definition at line 58 of file file.c.

59 {
60  static char path[MSDOS_NAME * 4 + 2];
61  char *p;
62  int i, j;
63 
64  p = path;
65  for (i = j = 0; i < 8; i++)
66  if (fixed[i] != ' ') {
67  while (j++ < i)
68  *p++ = ' ';
69  put_char(&p, fixed[i]);
70  }
71  if (strncmp((const char *)(fixed + 8), " ", 3)) {
72  *p++ = '.';
73  for (i = j = 0; i < 3; i++)
74  if (fixed[i + 8] != ' ') {
75  while (j++ < i)
76  *p++ = ' ';
77  put_char(&p, fixed[i + 8]);
78  }
79  }
80  *p = 0;
81  return path;
82 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
static void put_char(char **p, unsigned char c)
Definition: file.c:34
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MSDOS_NAME
Definition: msdos_fs.h:46
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
const char * path
Definition: file.c:2510
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by file_modify(), report_unused(), test_CreateFile(), test_file_all_name_information(), and test_file_name_information().

◆ file_type()

FD_TYPE file_type ( FDSC **  curr,
char fixed 
)

Definition at line 221 of file file.c.

222 {
223  FDSC **this;
224 
225  if ((this = file_find(curr, fixed)))
226  return (*this)->type;
227  return fdt_none;
228 }
static FDSC ** file_find(FDSC **dir, char *fixed)
Definition: file.c:198
FD_TYPE type
Definition: file.h:32
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
Definition: file.h:28
Definition: file.h:30

Referenced by add_file(), CVfdShExt::DoVfdDrop(), map_acemask(), map_dacl_2_nfs4acl(), OnImage(), OnTarget(), Open(), PrintImageInfo(), Save(), UpdateImageInfo(), VfdImageTip(), and VfdOpenImage().

◆ file_unused()

void file_unused ( void  )

Definition at line 269 of file file.c.

270 {
272 }
FDSC * fp_root
Definition: file.c:32
static void report_unused(FDSC *this)
Definition: file.c:253

Referenced by VfatChkdsk().

Variable Documentation

◆ fp_root

FDSC* fp_root

Definition at line 32 of file file.c.

Referenced by file_add(), file_unused(), and scan_root().