Page 1 of 1

Problem with directorydropped() on Windows

Posted: Sun Dec 22, 2024 12:10 pm
by eaaakb
Hi there. New to LÖVE, but not to Lua, and writing an application to process astrophotography images in real time using shaders.

Need to access the file system, so using love.filesystem.directorydropped() to do so. It works just fine on a Mac, but fails under Windows.

I’ve condensed the problem code to a single function:

Code: Select all

function love.directorydropped(folder)
  local fileseparator = package.config:sub(1,1)
  local mountpoint = "folder"

  print "folder dropped "

  local mount = love.filesystem.mount(folder, mountpoint)
  print("mounted ", mount)

  local dir = love.filesystem.getDirectoryItems(mountpoint)
  for i, item in ipairs(dir) do
    print(i, item)
  end

  local filename = dir[1]
  local path = mountpoint .. fileseparator .. filename
  local file, errorstr = love.filesystem.newFile(path, 'r')
  print(tostring(file))
  print(errorstr)

end
I’m using the standard Lua package.config to grab the appropriate file path separator '/' or '\' for the system.

Running on widows and dropping a folder with three files in it gives the following.

Code: Select all

folder dropped
mounted    true
1    a.txt
2    b.txt
3    c.txt
nil
Could not open file folder\a.txt. Does not exist.
This seems very wrong.

An help/insights much appreciated.

Tony

Re: Problem with directorydropped() on Windows

Posted: Sun Dec 22, 2024 1:17 pm
by slime
The file separator when using love.filesystem on windows is / (forward slash).

Re: Problem with directorydropped() on Windows

Posted: Sun Dec 22, 2024 1:33 pm
by eaaakb
That's what I tried first.

The dropped folder name actually contains the \ separator when running on windows, so I thought I should match that?

Re: Problem with directorydropped() on Windows

Posted: Sun Dec 22, 2024 5:26 pm
by slime
Anything within the love.filesystem virtual filesystem uses /, so getDirectoryItems does, but the folder path in directorydropped doesn't.