Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:55 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMB CHECKING FOR A DIRECTORY

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 02:33am 25 Sep 2024
Copy link to clipboard 
Print this post

What is the neatest and efficient way of checking that a directory exists on the SDCARD and creating it if it doesn't ?

I would like to save data to eg \2024\LOGFILES\ & \2024\EVTFILES\

0A47
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 02:57am 25 Sep 2024
Copy link to clipboard 
Print this post

  Quote  MM.INFO(EXISTS FILE fname$)
Returns 1 if the file specified exists, returns -1 if fname$ is a directory,
otherwise returns 0.

MM.INFO(EXISTS DIR dirname$)
Returns a Boolean indicating whether the directory specified exits.

MKDIR dir$
Make, or create, the directory ‘dir$’ on the default Flash Filesystem or SD
Card


There may be a typo in the top one. The way it actually works makes more sense.
> ? MM.INFO(EXISTS dir "Temp")
1
> ? MM.INFO(EXISTS file "Temp")
0>

Edited 2024-09-25 13:13 by phil99
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6097
Posted: 03:08am 25 Sep 2024
Copy link to clipboard 
Print this post

If the version of MMBasic you are using doesn't have MM.INFO(EXISTS

'
f$ = DIR$("2024/logfiles", DIR)
IF f$ = "" THEN
PRINT "does not exist"
ENDIF




Jim
VK7JH
MMedit   MMBasic Help
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 03:13am 25 Sep 2024
Copy link to clipboard 
Print this post

Thanks Phil, my question was a bit vague as I am looking at an older Armmite F4 and the reference in the handbook is:

MM.ERRNO
Is set to the error number if a statement involving the SD card fails or zero if
the operation succeeds. This is dependent on the setting of OPTION
ERROR. The possible values for MM.ERRNO are:
0 = No error
1 = No SD card found
2 = SD card is write protected
3 = Not enough space
6 = Cannot find file
7 = Cannot find file or directory
8 = Cannot create directory
12 = Hardware error
13 = File system error
14 = Directory not empty
16 = Syntax or general programming error

0A47
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 03:30am 25 Sep 2024
Copy link to clipboard 
Print this post

You could update to F4 5.07.02. It has a lot of the latest features added.
https://www.thebackshed.com/forum/ViewTopic.php?TID=16169&P=6#211904
  A consolidated manual for the Armmite F4 DRAFT 3 - 5.07.02 Beta 2 said  
MM.INFO(EXISTS FILE file$)
Returns 1 if the file specified exists, returns -2 if fname$ is a directory,
otherwise returns 0
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 03:43am 25 Sep 2024
Copy link to clipboard 
Print this post

  Quote  You could update to F4 5.07.02. It has a lot of the latest features added


Unfortunately, the target F4 is in a remote location and I can only access it via the console and there is no way to change the jumpers to re-flash it.  

0A47
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 04:50am 25 Sep 2024
Copy link to clipboard 
Print this post

I should add the reason for the directory need is that the F4 had refused to read/write to the 16GB SD card. I travelled there a few days ago and replaced a 32Gb SD Card. I can read the 16Gb SD in the PC it shows around 350MB used but 2665 files in the root directory and I think it has reached some sort of limit and I might be able to make it last longer by using dated directories.

0A47
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024