Distributed version works now, hopefully!

This commit is contained in:
shru 2018-12-14 21:49:12 -05:00
parent c1f466af8e
commit 5fffdcc659
3 changed files with 19 additions and 10 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
data/*

View file

@ -30,10 +30,14 @@ do
end end
-- function love.load() -- function love.load()
-- -- readPXM('Pole.pxm') -- local sourcePath = lf.getSourceBaseDirectory()
-- -- readTSC('Pole.tsc', 'Testing.tsc') -- local info = lf.getInfo(sourcePath .. '/data')
-- -- writeTSC('Testing.tsc') -- local items = lf.getDirectoryItems(sourcePath)
-- -- readTSC('TestingEncoded.tsc', 'TestingDecoded.tsc') -- print(Serpent.block(items))
-- print(Serpent.block(info))
-- if info == nil then
-- print()
-- end
-- end -- end
function love.directorydropped(path) function love.directorydropped(path)
@ -66,9 +70,15 @@ function love.directorydropped(path)
end end
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. -- Write modified files.
for filename, tscFile in pairs(tscFiles) do for filename, tscFile in pairs(tscFiles) do
local path = '/data/Stage/' .. filename local path = sourcePath .. '/data/Stage/' .. filename
tscFile:writeTo(path) tscFile:writeTo(path)
end end

View file

@ -63,13 +63,11 @@ function C:replaceItem(replacement)
end end
function C:writeTo(path) function C:writeTo(path)
local encoded = self:_codec(self._text, 'encode') logInfo('writing TSC to: ' .. path)
local filepath = lf.getSourceBaseDirectory() .. path local file, err = io.open(path, MODE_WRITE_ERASE_EXISTING)
logInfo('writing TSC to: ' .. filepath)
local file, err = io.open(filepath, MODE_WRITE_ERASE_EXISTING)
assert(err == nil, err) assert(err == nil, err)
local encoded = self:_codec(self._text, 'encode')
file:write(encoded) file:write(encoded)
file:flush() file:flush()
file:close() file:close()