aboutsummaryrefslogtreecommitdiff
path: root/src/ext/readdir.c
blob: 5f79e6730254e839aab2ff4d7f3036392bb82326 (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * reddir.c - FUSE read directory function
 *
 *  Created on: Mar 14, 2012
 *      Author: mg
 *
 * Read directory
 *
 * This supersedes the old getdir() interface.  New applications
 * should use this.
 *
 * The filesystem may choose between two modes of operation:
 *
 * 1) The readdir implementation ignores the offset parameter, and
 * passes zero to the filler function's offset.  The filler
 * function will not return '1' (unless an error happens), so the
 * whole directory is read in a single readdir operation.  This
 * works just like the old getdir() method.
 *
 * 2) The readdir implementation keeps track of the offsets of the
 * directory entries.  It uses the offset parameter and always
 * passes non-zero offset to the filler function.  When the buffer
 * is full (or an error happens) the filler function will return
 * '1'.
 *
 * Introduced in version 2.3
 */

#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
//#include <string.h>
//#include <errno.h>
//#include <glib.h>
#include <fuse.h>
//#include <GNUnet/gnunet_ecrs_lib.h>
#include <gnunet-fuse.h>





int gn_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
	off_t offset, struct fuse_file_info *fi)
{

	//char* track = "mal";
	//char  var[strlen(directory)+strlen(track)+1];
	//memcpy(var,directory,strlen(directory));
	//int len = strlen(directory);
// GNUNET_asprintf();

	if (strcmp(path, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount") == 0)
	{
		filler(buf, ".", NULL, 0);
		filler(buf, "..", NULL, 0);
		filler(buf, "/home/mg/gnunet-fuse5/gnunet-fuse/src/ext/mount"+1, NULL, 0);
		return 0;
	}

	/*

	else if (strcmp(path, directory) == 0)  // mounted directory with content
	{
		filler(buf, ".", NULL, 0);
		filler(buf, "..", NULL, 0);
		filler(buf, track+len, NULL, 0); // path to directory mal
		return 0;
	}

	 */

	else return -ENOENT;

}































/*

static const char *archive_path = "/";
static const char *archive_str = "/Archive\n";

static const char *britney_path = "/Britney Spears";
static const char *britney_str = "Britney Spears\n";

static const char *britney_br_path = "/Britney Spears/Britney";
static const char *britney_br_str = "Britney\n";

static const char *b_br_1_path = "/Britney Spears/Britney/I'm a Slave 4 U";
	static const char *b_br_1_str = "3:23 U\n";



if(strcmp(path, "/") == 0)
		    {
			filler(buf, ".", NULL, 0);
			filler(buf, "..", NULL, 0);

			filler(buf, britney_path + 1, NULL, 0);
			//filler(buf, metallica_path + 1, NULL, 0);
			return 0;
		    }

		 else  if(strcmp(path, "/Britney Spears") == 0)
		    {
			filler(buf, ".", NULL, 0);
			filler(buf, "..", NULL, 0);
			//filler(buf, britney_omt_path + 16, NULL, 0);
			filler(buf, britney_br_path + 16, NULL, 0);
			return 0;
		    }

		 else  if(strcmp(path,  britney_br_path) == 0) // ab hier das album britney
		    {
		 	filler(buf, ".", NULL, 0);
		 	filler(buf, "..", NULL, 0);
		 	filler(buf, b_br_1_path + 24 , NULL, 0);

		 	return 0;
		    }

		 else return -ENOENT;



*/