diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60baa9c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +data/* diff --git a/src/main.lua b/src/main.lua index 15b39c0..88a1b92 100644 --- a/src/main.lua +++ b/src/main.lua @@ -30,10 +30,14 @@ do end -- function love.load() --- -- readPXM('Pole.pxm') --- -- readTSC('Pole.tsc', 'Testing.tsc') --- -- writeTSC('Testing.tsc') --- -- readTSC('TestingEncoded.tsc', 'TestingDecoded.tsc') +-- local sourcePath = lf.getSourceBaseDirectory() +-- local info = lf.getInfo(sourcePath .. '/data') +-- local items = lf.getDirectoryItems(sourcePath) +-- print(Serpent.block(items)) +-- print(Serpent.block(info)) +-- if info == nil then +-- print() +-- end -- end function love.directorydropped(path) @@ -66,9 +70,15 @@ function love.directorydropped(path) end end + local sourcePath = lf.getSourceBaseDirectory() + + -- Create /data/Stage if it doesn't already exist. + local command = ('mkdir "%s"'):format(sourcePath .. '/data/Stage') + os.execute(command) -- HERE BE DRAGONS!!! + -- Write modified files. for filename, tscFile in pairs(tscFiles) do - local path = '/data/Stage/' .. filename + local path = sourcePath .. '/data/Stage/' .. filename tscFile:writeTo(path) end diff --git a/src/tsc_file.lua b/src/tsc_file.lua index 8705762..f981290 100644 --- a/src/tsc_file.lua +++ b/src/tsc_file.lua @@ -63,13 +63,11 @@ function C:replaceItem(replacement) end function C:writeTo(path) - local encoded = self:_codec(self._text, 'encode') + logInfo('writing TSC to: ' .. path) - local filepath = lf.getSourceBaseDirectory() .. path - logInfo('writing TSC to: ' .. filepath) - - local file, err = io.open(filepath, MODE_WRITE_ERASE_EXISTING) + local file, err = io.open(path, MODE_WRITE_ERASE_EXISTING) assert(err == nil, err) + local encoded = self:_codec(self._text, 'encode') file:write(encoded) file:flush() file:close()