Diff

Differences From Artifact [2be0a65534]:

To Artifact [d0cf525af8]:


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
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
157
158
159
160
161
162
163







-
+

-









+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
















-
+


-

















-
+
+

+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+







	pathLen = strlen(path);

<?= [dict get $hashTable body] ?>

	return(XVFS_NAME_LOOKUP_ERROR);
}

static const char **xvfs_<?= $::xvfs::fsName ?>_getChildren(const char *path, Tcl_WideInt *count) {
static const char **xvfs_<?= $::xvfs::fsName ?>_getChildren(const char *path, long inode, Tcl_WideInt *count) {
	const struct xvfs_file_data *fileInfo;
	long inode;

	/*
	 * Validate input parameters
	 */
	if (count == NULL) {
		return(NULL);
	}
	
	/*
	 * Use user-supplied inode, or look up the path
	 */
	if (inode == XVFS_INODE_NULL) {
		/*
	 * Get the inode from the lookup function
	 */
	inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
	if (inode == XVFS_NAME_LOOKUP_ERROR) {
		*count = XVFS_RV_ERR_ENOENT;
		return(NULL);
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			*count = XVFS_RV_ERR_ENOENT;
			return(NULL);
		}
	}
	
	fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];

	/*
	 * Ensure this is a directory
	 */
	if (fileInfo->type != XVFS_FILE_TYPE_DIR) {
		*count = XVFS_RV_ERR_ENOTDIR;
		return(NULL);
	}
	
	*count = fileInfo->size;
	return(fileInfo->data.dirChildren);
}

static const unsigned char *xvfs_<?= $::xvfs::fsName ?>_getData(const char *path, Tcl_WideInt start, Tcl_WideInt *length) {
static const unsigned char *xvfs_<?= $::xvfs::fsName ?>_getData(const char *path, long inode, Tcl_WideInt start, Tcl_WideInt *length) {
	const struct xvfs_file_data *fileInfo;
	Tcl_WideInt resultLength;
	long inode;

	/*
	 * Validate input parameters
	 */
	if (length == NULL) {
		return(NULL);
	}
	
	if (start < 0) {
		*length = XVFS_RV_ERR_EINVAL;
		return(NULL);
	}
	
	if (*length < 0) {
		*length = XVFS_RV_ERR_EINVAL;
		return(NULL);
	}
	


	/*
	 * Use user-supplied inode, or look up the path
	 */
	if (inode == XVFS_INODE_NULL) {
		/*
	 * Get the inode from the lookup function
	 */
	inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
	if (inode == XVFS_NAME_LOOKUP_ERROR) {
		*length = XVFS_RV_ERR_ENOENT;
		return(NULL);
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			*length = XVFS_RV_ERR_ENOENT;
			return(NULL);
		}
	}
	
	fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];

	/*
	 * Ensure this is a file that can be read
	 */
174
175
176
177
178
179
180
181

182
183
184
185
186
187
188
189
190
191
192




193
194
195
196
197






198
199
200
201
202
203
204
183
184
185
186
187
188
189

190
191

192
193
194
195
196
197
198
199
200
201
202
203
204





205
206
207
208
209
210
211
212
213
214
215
216
217







-
+

-









+
+
+
+
-
-
-
-
-
+
+
+
+
+
+








	/*
	 * Return the data
	 */
	return(fileInfo->data.fileContents + start);
}

static int xvfs_<?= $::xvfs::fsName ?>_getStat(const char *path, Tcl_StatBuf *statBuf) {
static int xvfs_<?= $::xvfs::fsName ?>_getStat(const char *path, long inode, Tcl_StatBuf *statBuf) {
	const struct xvfs_file_data *fileInfo;
	long inode;

	/*
	 * Validate input parameters
	 */
	if (!statBuf) {
		return(XVFS_RV_ERR_EINVAL);
	}
	
	/*
	 * Use user-supplied inode, or look up the path
	 */
	if (inode == XVFS_INODE_NULL) {
		/*
	 * Get the inode from the lookup function
	 */
	inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
	if (inode == XVFS_NAME_LOOKUP_ERROR) {
		return(XVFS_RV_ERR_ENOENT);
		 * Get the inode from the lookup function
		 */
		inode = xvfs_<?= $::xvfs::fsName ?>_nameToIndex(path);
		if (inode == XVFS_NAME_LOOKUP_ERROR) {
			return(XVFS_RV_ERR_ENOENT);
		}
	}
	
	fileInfo = &xvfs_<?= $::xvfs::fsName ?>_data[inode];
	
	statBuf->st_dev   = <?= [zlib adler32 $::xvfs::fsName 0] ?>;
	statBuf->st_rdev  = <?= [zlib adler32 $::xvfs::fsName 0] ?>;
	statBuf->st_ino   = inode;