Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

upper and lower cases on file extensions
Started by thithous Mar 20 2019 06:51 PM

- - - - -
5 replies to this topic
uppercase lowercase extensions simulator differs on disk case of file

Best Answer schizoid2k , 21 March 2019 - 04:26 AM

Alan,

 

I see your point.  I guess the best way is to standardize on a naming convention as you stated.

 

Also, perhaps cycle through the list of files, change them to a standard lower or upper, then do compares... not sure based on that snippet of code.  I agree that "wav" and "WAV" files would be somewhat more difficult to manage.

 

Cheers!

--john

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

thithous

[GLOBAL: userInfoPane.html]
thithous
  • Observer

  • 13 posts
  • Corona SDK

hi im having a problem case of file name xyz with differs on disk
 
i want to compare the string extension, but the simulator treats it like "a.png" is equal to "a.PNG".
 
 
my program is making a comparation this way:
 
if fileExists(atributos.pasta .. "/Sons/"..nome..".wav") then
    table.insert( audioFiles, nome..".wav" )
elseif fileExists(atributos.pasta .. "/Sons/"..nome..".mp3") then
    table.insert( audioFiles, nome..".mp3" )
elseif fileExists(atributos.pasta .. "/Sons/"..nome..".WAV") then
    table.insert( audioFiles, nome..".WAV" )
end
 
it ends up adding a wrong file name to my 'dllTelasSons.txt' file, that gives an error on android, since android cares about upper and lower cases. Is there a way for the simulator to not accept the uppers and lower cases as equal?
 
thanks in advance
 
my best regards

 

Attached Thumbnails

  • Capturar.PNG
  • Capturar2.PNG

  • thithous likes this

[TOPIC: post.html]
#2

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 911 posts
  • Corona SDK

I believe this is handled by the operating system rather than Corona itself. 

 

My suggestion would be to change your files to all use the same naming convention for consistency. Personally it would drive me crazy to deal with a directory where the file names jump up and down in case size, and where some have spaces while some use camelCase or underscores etc.



[TOPIC: post.html]
#3

schizoid2k

[GLOBAL: userInfoPane.html]
schizoid2k
  • Contributor

  • 562 posts
  • Corona SDK

Check out string.upper() and string.lower()

 

I would also recommend what Alan said... use a common naming convention, or just convert everything to lower case in code.



[TOPIC: post.html]
#4

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 911 posts
  • Corona SDK

string.upper() and string.lower() may actually just compound thithous's problem. 

 

If this is already returning true when the case doesn't match:

if fileExists(atributos.pasta .. "/Sons/"..nome..".wav") then

then so will this even when the file name is actually lower case:

if fileExists(string.upper(atributos.pasta .. "/Sons/"..nome..".wav")) then


[TOPIC: post.html]
#5

schizoid2k

[GLOBAL: userInfoPane.html]
schizoid2k
  • Contributor

  • 562 posts
  • Corona SDK

  Best Answer

Alan,

 

I see your point.  I guess the best way is to standardize on a naming convention as you stated.

 

Also, perhaps cycle through the list of files, change them to a standard lower or upper, then do compares... not sure based on that snippet of code.  I agree that "wav" and "WAV" files would be somewhat more difficult to manage.

 

Cheers!

--john



[TOPIC: post.html]
#6

thithous

[GLOBAL: userInfoPane.html]
thithous
  • Observer

  • 13 posts
  • Corona SDK

thanks for the posts.
Your answers helped a lot.

Unfortunately it is something that comes from windows as you have said.

ill follow schozoid2k advice and make a code that cycles through the list of files and rename all extensions to lower case, even if they already are like that. it can solve the problem more easily.

thanks for the help,

 

my best regards.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: uppercase, lowercase, extensions, simulator, differs on disk, case of file