Strange issue when i trying to get absolute path to Resource Directory on MacOS

Corona Simulator Version 2019.3473 (2019.3.27)

macOS

Hello,

When i using code:

local pathImages = system.pathForFile("Images/arrow.png", system.ResourceDirectory) print(pathImages) -- got only "Images/arrow.png"

I expect to get absolute path but variable pathImage contain only value of first argument of system.pathForFile.

Also if i trying to concatenate two string like:

print( "/Users/gennady/Documents/dev/Corona/ToTest" .. "/Images" )

The result of this print will be “Images”

I think it’s strange. It’s bug or feature? Or something else?

What is your end goal here?

i.e. Why do you need to absolute path and what do you want to use it for?

Telling us that, will help us to help you.

We are write tests for our project.

Current goal is to find unused pictures.

We are parse code and get all *.png and *.jpg and then check it on existing in Image folder.

It works fine on Windows but not on MacOS.

Please try this example and see if it works for you:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2019/04/absolutePaths.zip

Specifically, the part using SSK files: https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/files/#files-library-sskfiles

Source is provided as zipped project above, but this is the entire example in main.lua:

io.output():setvbuf("no") display.setStatusBar(display.HiddenStatusBar) -- ===================================================== require "ssk2.loadSSK" \_G.ssk.init( { measure = false } ) -- ===================================================== local imagePath = "images/smiley.png" local test = display.newImageRect( imagePath , 40, 40 ) test.x = centerX test.y = centerY - 200 -- use standard corona features local path1 = system.pathForFile( imagePath ) local label1 = display.newText( path1, centerX, centerY - 100, nil, 14 ) -- Now use ssk files.\* - https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/files/ local path2 = ssk.files.resource.getPath( imagePath ) path2 = ssk.files.util.repairPath( path2, true ) local label2 = display.newText( path2, centerX, centerY, nil, 14 )

This example uses SSK’s files library to find the path instead of Corona’s feature.

In the both cases i get absolute path if output into newText but function print is output only “images/smiley.png”.

It confused me.

I think in my case i must check another code. Maybe error in other place.
Thanks for helping.

The printing problem is likely an error you your code or you running an older copy.

You can add the same print statements to my example and they will print whatever is shown by the text object.

I found solution.

system.pathForFile(nil, system.ResourceDirectory)

Somewere in the code we used system.pathForFile("", system.ResourceDirectory) but it’s not good on mac.

When i change all on nil test was fixed.

What is your end goal here?

i.e. Why do you need to absolute path and what do you want to use it for?

Telling us that, will help us to help you.

We are write tests for our project.

Current goal is to find unused pictures.

We are parse code and get all *.png and *.jpg and then check it on existing in Image folder.

It works fine on Windows but not on MacOS.

Please try this example and see if it works for you:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2019/04/absolutePaths.zip

Specifically, the part using SSK files: https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/files/#files-library-sskfiles

Source is provided as zipped project above, but this is the entire example in main.lua:

io.output():setvbuf("no") display.setStatusBar(display.HiddenStatusBar) -- ===================================================== require "ssk2.loadSSK" \_G.ssk.init( { measure = false } ) -- ===================================================== local imagePath = "images/smiley.png" local test = display.newImageRect( imagePath , 40, 40 ) test.x = centerX test.y = centerY - 200 -- use standard corona features local path1 = system.pathForFile( imagePath ) local label1 = display.newText( path1, centerX, centerY - 100, nil, 14 ) -- Now use ssk files.\* - https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/files/ local path2 = ssk.files.resource.getPath( imagePath ) path2 = ssk.files.util.repairPath( path2, true ) local label2 = display.newText( path2, centerX, centerY, nil, 14 )

This example uses SSK’s files library to find the path instead of Corona’s feature.

In the both cases i get absolute path if output into newText but function print is output only “images/smiley.png”.

It confused me.

I think in my case i must check another code. Maybe error in other place.
Thanks for helping.

The printing problem is likely an error you your code or you running an older copy.

You can add the same print statements to my example and they will print whatever is shown by the text object.

I found solution.

system.pathForFile(nil, system.ResourceDirectory)

Somewere in the code we used system.pathForFile("", system.ResourceDirectory) but it’s not good on mac.

When i change all on nil test was fixed.