Filesystem.Open() documentation

http://forum.arduino.cc/index.php?topic=198355.msg1463525#msg1463525

Related to the above post:
I had the same question about File_Append but since this is an agreed additional mode (FILE_APPEND) why isn't this in the description for this function here:

I also have some confusion about what data type can be used for the "filename" input. The YunFileIOOpen website above says "char" without much explanation. However the yun datalogger example puts the filename in double quotes which I believe means it is a string. Which one is it? I tried a string variable but got an error, so I looked up the function documentation but that didn't help much.

Thanks in advance

Yes, there are some omissions all over the reference pages, and the formatting is less than ideal. The most reliable source of information is looking at the source code: "Use the Source, Luke!"

Looking at the Bridge library's FileIO.h, very near the top we can immediately see the defines for FILE_READ and FILE_WRITE, as well as the elusive FILE_APPEND. Starting in your Arduino application folder, the file is libraries/Bridge/src/FileIO.h

A few lines later we see the declaration of the constructor:

File(const char *_filename, uint8_t _mode, BridgeClass &b = Bridge);

The filename parameter is a const char *, a pointer to a character, which the function promises it will not try to change (that's what the const means.) Recalling that in C and C++ there is no difference between a pointer and array, we can assume it is expecting a pointer to a series of characters (an array) which tells us that it probably wants a C style character string (sequence of characters in double quotes.)

You say you tried a string variable, but I'm going to guess you really tried a String variable. They are not the same, capitalization is significant:

  • A String is class that encapsulates a character strong no, and gives several string manipulation functions.
  • A string is an array of characters with a NULL terminator. It can be assigned using characters in double quotes, but you must use standard C foundations or array access to manipulate them.

How can we improve the documentation? The documentation says to use the forum but it doesn't look like changes are being made.

It seems that if the documentation were a wiki it would be more up to date and thorough.

That being said, thank you for your response. Yes, I did put the wrong capitalization in my post and I did try a String. That was based off of the example using double quotes though. I will try a string and see if that does the trick.

Thanks!

@ShapeShifter,
I'll write this up. Can I use your text? I will, of course, give you credit.
Is there anything to add?

Jesse

Sure, you can do whatever you want with my text, but as it is, it's written in a more conversational tone, and not what I would consider a reasonable documentation format. Use what you want, but I'll bet it won't be very recognizable by the time you're done.

ShapeShifter:
Sure, you can do whatever you want with my text, but as it is, it's written in a more conversational tone, and not what I would consider a reasonable documentation format. Use what you want, but I'll bet it won't be very recognizable by the time you're done.

Okay. I'll give it a try.

I re-read your explanation. It is as bad as I feared. It turns out this is the C++ish that Yun uses and I complain about. I'll write it up as part of a larger explanation. Which means it won't get publish for a while. I'm still head down/elbows up on my Phonegap Projects.

Jesse