## [solved] problem with the path from getSaveDirectory

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Dudenheit
Prole
Posts: 5
Joined: Wed Dec 17, 2014 7:40 am

### [solved] problem with the path from getSaveDirectory

Hi,

I tried to read some files at start, which are saved in the standard-save-directory of love2d. The directory exists and I managed to write some file there, also.
The files are known by the engine, for example with this code from the wiki:

Code: Select all

	local dir = ""
local files = love.filesystem.getDirectoryItems(dir)
for k, file in ipairs(files) do
print(k .. ". " .. file) --outputs something like "1. main.lua"
end

all file-names (of the save-directory AND of the directory, where the main.lua-file is) are listed in the console.

Now I wanted (as I need) the files only, which are in the save-directory.
I tried

Code: Select all

local str_path = "file://"..love.filesystem.getSaveDirectory()
and

Code: Select all

local str_path = love.filesystem.getSaveDirectory()
but both paths do not exist?
(I tested this with love.filesystem.exists, which returns a true or false)
Is there a hint, how I could handle this? Is there a problem with the paths if I use windows (instead of linux?) My username has no "special" characteres...

Thanks for reading so far :-)

EDIT: Solved, thanks a lot!!
Last edited by Dudenheit on Sun Apr 05, 2015 8:54 am, edited 1 time in total.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: problem with the path from getSaveDirectory

Currently there is no way to do this, because PhysFS doesn't tell LÖVE where it gets the files it finds.

undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

### Re: problem with the path from getSaveDirectory

I ran into the same Problem the other day.
I wanted to delete all the Data in the save directory, and I got it working - but not without calling love.filesystem.remove for every file in the game directory as well...

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: problem with the path from getSaveDirectory

If you do need to separate content, you could make it identifiable, for instance by putting it in a (different) subdirectory.

slime
Solid Snayke
Posts: 2882
Joined: Mon Aug 23, 2010 6:45 am
Contact:

### Re: problem with the path from getSaveDirectory

You could use [wiki]love.filesystem.getRealDirectory[/wiki], like so:

Code: Select all

for i, filename in ipairs(love.filesystem.getDirectoryItems(folder)) do
local filepath = folder.."/"..filename

if love.filesystem.getRealDirectory(filepath) == love.filesystem.getSaveDirectory() then
-- The file is in the save directory.
end
end


### Who is online

Users browsing this forum: No registered users and 9 guests