Diff

Differences From Artifact [842e8c1c67]:

To Artifact [832d8bb370]:


1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
1
2
3
4
5
6
7
8
9




10

11
12
13
14
15
16
17









-
-
-
-
+
-







#! /usr/bin/env tclsh

namespace eval ::xvfs {}
namespace eval ::xvfs::callback {}

set ::xvfs::_xvfsDir [file dirname [info script]]

# Functions
proc ::xvfs::_emitLine {line} {
	if {[info command ::minirivet::_emitOutput] ne ""} {
		::minirivet::_emitOutput "${line}\n"
	} else {
		puts $line
	lappend ::xvfs::_emitLine $line
	}
}

proc ::xvfs::printHelp {channel {errors ""}} {
	if {[llength $errors] != 0} {
		foreach error $errors {
			puts $channel "error: $error"
		}
127
128
129
130
131
132
133
134
135
136
137

138
139
140

141
142

143
144
145
146
147
148
149
123
124
125
126
127
128
129

130
131

132
133
134

135
136
137
138
139
140
141
142
143
144
145







-


-
+


-
+


+







			return -code error "Unable to process $inputFile, unknown type: $fileInfo(type)"
		}
	}

	::xvfs::_emitLine "\t\{"
	::xvfs::_emitLine "\t\t.name = \"[sanitizeCString $outputFile]\","
	::xvfs::_emitLine "\t\t.type = $type,"
	::xvfs::_emitLine "\t\t.size = $size,"
	switch -exact -- $fileInfo(type) {
		"file" {
			::xvfs::_emitLine "\t\t.data.fileContents = (const unsigned char *) $data"
			::xvfs::_emitLine "\t\t.data.fileContents = (const unsigned char *) $data,"
		}
		"directory" {
			::xvfs::_emitLine "\t\t.data.dirChildren  = $children"
			::xvfs::_emitLine "\t\t.data.dirChildren  = $children,"
		}
	}
	::xvfs::_emitLine "\t\t.size = $size"
	::xvfs::_emitLine "\t\},"
}

proc ::xvfs::processDirectory {fsName directory {subDirectory ""}} {
	set subDirectories [list]
	set outputFiles [list]
	set workingDirectory [file join $directory $subDirectory]
278
279
280
281
282
283
284



285
286
287
288
289
290
291
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290







+
+
+







	}

	## 3. Start processing directory and producing initial output
	set ::xvfs::outputFiles [processDirectory $fsName $rootDirectory]

	set ::xvfs::fsName $fsName
	set ::xvfs::rootDirectory $rootDirectory

	# Return the output
	return [join $::xvfs::_emitLine "\n"]
}

proc ::xvfs::run {args} {
	uplevel #0 { package require minirivet }

	set ::xvfs::argv $args
	::minirivet::parse [file join $::xvfs::_xvfsDir xvfs.c.rvt]