Page 1 of 1

No SD Card – No Error

Posted: March 5th, 2018, 11:55 am
by leulae
Dear all,

pathname(CSEntryExternal) – No SD Card – No Error

I wrote backup operation for Android with the help of pathname(CSEntryExternal) function.

Code: Select all

string backupToSD = pathname(CSEntryExternal) + maketext("myfolder/Backup%d",timestamp());
filecopy(pathname(Application) + "Data/filename.DAT",backupToSD);
It Backups to SD Card

The problem is,
when there is no SD card it does not give an error.

Need to detect a method to check/verify SD card present or not

Please help on this regard

Thanks in advance

Leulae

Re: No SD Card – No Error

Posted: March 5th, 2018, 2:34 pm
by Gregory Martin
I don't have a device with a SD card so I can't test this, but the dircreate function should return 1 if a directory exists, so this might work:
if dircreate(pathname(CSEntryExternal)) = 0 then
    errmsg("A SD card is not present.");
endif;

Re: No SD Card – No Error

Posted: March 5th, 2018, 5:27 pm
by josh
Did you try checking the value of pathname(CSEntryExternal) to make sure it is not empty? I think it should return either and empty string or "<invalid path>" if there is no SD card. You could check this with code like:
if pathname(CSEntryExternal) = "" or pathname(CSEntryExternal) = "<invalid path>" then
    
errmsg("Please insert an SD card");
endif;
Also the filecopy should return default if there is no SD card so you could check that:
if filecopy(pathname(Application) + "Data/filename.DAT",backupToSD) = default then
    
errmsg("Please insert an SD card");
endif;

Re: No SD Card – No Error

Posted: March 7th, 2018, 3:46 am
by leulae
Thank you all for your guidance

Leulae