[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
Before you make a thread asking for help, read this.
Post Reply
Dudenheit
Prole
Posts: 5
Joined: Wed Dec 17, 2014 7:40 am

[solved] problem with the path from getSaveDirectory

Post by Dudenheit » Sat Mar 21, 2015 5:04 pm

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.

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

Re: problem with the path from getSaveDirectory

Post by Robin » Sat Mar 21, 2015 5:36 pm

Currently there is no way to do this, because PhysFS doesn't tell LÖVE where it gets the files it finds.
Help us help you: attach a .love.

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

Re: problem with the path from getSaveDirectory

Post by undef » Sat Mar 21, 2015 6:03 pm

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...
twitter | steam | indieDB

Check out quadrant on Steam!

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

Re: problem with the path from getSaveDirectory

Post by bartbes » Sat Mar 21, 2015 7:28 pm

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

User avatar
slime
Solid Snayke
Posts: 2820
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: problem with the path from getSaveDirectory

Post by slime » Sat Mar 21, 2015 9:05 pm

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

Post Reply

Who is online

Users browsing this forum: pgimeno and 8 guests