Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Strange issue when i trying to get absolute path to Resource Directory on MacOS
Started by Gent Apr 21 2019 06:43 PM

- - - - -
6 replies to this topic
macos simulator bug system.pathforfile
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Gent

[GLOBAL: userInfoPane.html]
Gent
  • Observer

  • 19 posts
  • Corona SDK

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?



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,594 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

Gent

[GLOBAL: userInfoPane.html]
Gent
  • Observer

  • 19 posts
  • Corona SDK

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.



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,594 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

Gent

[GLOBAL: userInfoPane.html]
Gent
  • Observer

  • 19 posts
  • Corona SDK

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.



[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,594 posts
  • Corona SDK

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.



[TOPIC: post.html]
#7

Gent

[GLOBAL: userInfoPane.html]
Gent
  • Observer

  • 19 posts
  • Corona SDK

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.




[topic_controls]
[/topic_controls]