-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdir.h
72 lines (63 loc) · 2.08 KB
/
dir.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef _MIMINO_DIR_H
#define _MIMINO_DIR_H
#include <sys/types.h>
#include <stdio.h>
#define TB_SIZE 0xE8D4A51000
#define GB_SIZE 0x3B9ACA00
#define MB_SIZE 0xF4240
#define KB_SIZE 0x3E8
typedef struct {
char *name;
int fd;
time_t last_mod;
mode_t mode;
off_t size;
int is_dir;
int is_link;
int is_broken_link;
int is_null;
} File;
#define NULL_FILE (File) { "???", -1, 0, 0, 0, 0, 0, 0, 1 }
typedef struct {
File *files;
size_t len;
File *dir_info;
} File_List;
File_List* ls(char *dir);
void free_file(File *f);
void free_file_parts(File *f);
void free_file_list(File_List *fl);
char* get_base_name(char *path);
char* cleanup_path(char *path);
char* resolve_path(char *p1, char *p2);
int read_file_info(File *f, char *path);
void print_file_info(FILE *f, File *file);
char* get_file_type_suffix(File *f);
char* get_human_file_size(off_t size);
char* get_human_file_perms(File *f);
#endif // _MIMINO_DIR_H
/*
struct dirent {
ino_t d_ino; // Inode number.
off_t d_off; // Not an offset; see below.
unsigned short d_reclen; // Length of this record.
unsigned char d_type; // Type of file; not supported
// by all filesystem types.
char d_name[256]; // Null-terminated filename.
};
struct stat {
dev_t st_dev; // ID of device containing file
ino_t st_ino; // Inode number
mode_t st_mode; // File type and mode
nlink_t st_nlink; // Number of hard links
uid_t st_uid; // User ID of owner
gid_t st_gid; // Group ID of owner
dev_t st_rdev; // Device ID (if special file)
off_t st_size; // Total size, in bytes
blksize_t st_blksize; // Block size for filesystem I/O
blkcnt_t st_blocks; // Number of 512B blocks allocated
struct timespec st_atim; // Time of last access
struct timespec st_mtim; // Time of last modification
struct timespec st_ctim; // Time of last status change
};
*/