Forum

> > CS2D > Scripts > Deleting a deprecated savefile
Forums overviewCS2D overview Scripts overviewLog in to reply

English Deleting a deprecated savefile

2 replies
To the start Previous 1 Next To the start

old Deleting a deprecated savefile

Alistaire
User Off Offline

Quote
1
2
3
4
5
6
7
8
if io.open('sys/lua/CSP_DungeonCrawler/Saves/weaponTable.lua') then
	local Result, ErrorString = os.remove('sys/lua/CSP_DungeonCrawler/Saves/weaponTable.lua')
	if not Result then
		print(ErrorString)
	end
end

> [14:52:15] sys/lua/CSP_DungeonCrawler/Saves/weaponTable.lua: Permission denied

So how would I have to delete this file?

old Re: Deleting a deprecated savefile

Starkkz
Moderator Off Offline

Quote
The problem is that when you opened the file with io.open you locked the use of writing/removing this file.

1
2
3
4
5
local f = io.open("dir here")
if f then
f:close()
-- chunk here
end

old Re: Deleting a deprecated savefile

Alistaire
User Off Offline

Quote
Thanks, I made this function to make it easier:

1
2
3
4
5
6
7
8
9
10
11
function deleteSave(path)
	local f = io.open(path)
	print('Deleting file '..path..'..')
	if f then
		f:close()
		os.remove(path)
		print('File '..path..' deleted!')
	else
		print('File '..path..' not found')
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview