Problem with directorydropped() on Windows

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
eaaakb
Prole
Posts: 2
Joined: Sun Dec 22, 2024 10:46 am

Problem with directorydropped() on Windows

Post 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
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Problem with directorydropped() on Windows

Post by slime »

The file separator when using love.filesystem on windows is / (forward slash).
eaaakb
Prole
Posts: 2
Joined: Sun Dec 22, 2024 10:46 am

Re: Problem with directorydropped() on Windows

Post 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?
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Problem with directorydropped() on Windows

Post by slime »

Anything within the love.filesystem virtual filesystem uses /, so getDirectoryItems does, but the folder path in directorydropped doesn't.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 10 guests