-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfs.c
More file actions
46 lines (38 loc) · 1001 Bytes
/
Copy pathfs.c
File metadata and controls
46 lines (38 loc) · 1001 Bytes
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
#include "fs.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//Cria um sistema de ficheiros (Tecnicofs)
tecnicofs new_tecnicofs(){
tecnicofs fs = malloc(sizeof(struct tecnicofs));
if (!fs) {
perror("failed to allocate tecnicofs");
exit(EXIT_FAILURE);
}
return fs;
}
void free_tecnicofs(tecnicofs fs){
free_tree(fs->bstRoot);
free(fs);
}
void create(tecnicofs fs, char *name, int inumber){
fs->bstRoot = insert(fs->bstRoot, name, inumber);
}
void delete(tecnicofs fs, char *name){
fs->bstRoot = remove_item(fs->bstRoot, name);
}
int lookup(tecnicofs fs, char *name){
node* searchNode = search(fs->bstRoot, name);
if ( searchNode ) return searchNode->inumber;
return 0;
}
void print_HashTab_tree(FILE * fp, tecnicofs* hashTab, int size){
int i;
for(i = 0; i < size; i++) print_tecnicofs_tree(fp, hashTab[i]);
}
void print_tecnicofs_tree(FILE * fp, tecnicofs fs){
print_tree(fp, fs->bstRoot);
}
int searchHash(char *name, int size) {
return hash(name, size);
}