-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheader.h
executable file
·80 lines (56 loc) · 1.78 KB
/
header.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
73
74
75
76
77
78
79
80
#include <sys/stat.h> //for stat function
#include <sys/types.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h> //for universal standard I/O
#include <dirent.h> //for directory handling
#include <string.h>
#include <stdlib.h>
typedef int BOOL;
#define TRUE 1
#define FALSE 0
#define SUCCESS 1
#define ERR_ACCESS 2
#define ERR_INVALID 3
#define ERR_CREATE 4
#define ERR_AUTHENTICATION 5
typedef struct
{
char name[255]; //name of file
int size; //size value
// if size = -1 : The file is directory and its open
// if size = -2 : The file is directory and its close
// if size > 0 : The file is regular file and its size
}FILEINFO;
//FILE SIZE
#define DIRECTORY_OPEN -1
#define DIRECTORY_CLOSE -2
typedef struct
{
char hardcoded[11];
char key;
int type; //type = 0 application define key
//type = 1 user defined key
}VALIDATION;
VALIDATION authentication;
//VALIDATION TYPE
#define APPLICATION_DEF 0
#define USER_DEF 1
int inputFd , outputFd; //file description
char *relativePath;
void helpInfo(); //display the user how to give input
char *dynamicConcat( char * , char *); //concate string to dynamic allocate variable
char *dynamicRemoveLast( char * , char ); //remove string after given character
void displayError(BOOL );
//file packer function declaration
BOOL filePack( char * , char * , int );
BOOL readDirectory( char* dirName);
BOOL readFile();
void InsertValidationCode( char *fileName , int key);
void writeFileInfo( char* dirName , int size );
// file unpacker function declaration
BOOL fileUnpack( char * , char * , int );
BOOL writeFile( char* fileName , int size);
BOOL checkValidation( char* fileName , int key);
BOOL checkDirectoryExist( char* dirName );
BOOL searchFile( char* fileName[] , int filecount , int key);