Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: SirCmpwn on December 12, 2010, 10:29:50 pm

Title: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 10:29:50 pm
Hello,
How do I do all of the above?
Title: Re: Reading/Writing Files, Listing Directories
Post by: jnesselr on December 12, 2010, 10:31:23 pm
In C. There are functions to read and write files (fwrite I think).

For directories, try this:
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046380353&id=1044780608

EDIT: http://en.wikipedia.org/wiki/C_file_input/output for reading and writing.
Title: Re: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 10:33:22 pm
I know about the file functions, but now how to use them properly, and the docs don't help :(
The directory example uses dir.h, which is not available for download anywhere nearby.
Title: Re: Reading/Writing Files, Listing Directories
Post by: jnesselr on December 12, 2010, 10:35:53 pm
I know about the file functions, but now how to use them properly, and the docs don't help :(
The directory example uses dir.h, which is not available for download anywhere nearby.
I see.  IIRC, you open the file, and read it. Haven't done that in a while. I know you open it, read the file, and then close it. Not sure otherwise.
Title: Re: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 10:39:22 pm
IIRC, you open the file, and read it
/me slaps graphmastur
Title: Re: Reading/Writing Files, Listing Directories
Post by: jnesselr on December 12, 2010, 10:49:36 pm
IIRC, you open the file, and read it
/me slaps graphmastur
Lol, sorry. It's platform specific, IIRC, so you are best off using a methods within #ifdef (Wait, that's C right?) based on the OS.  So, yeah, not exactly sure. I've done it before, but only when writing a stream to a log file, and that was a year ago, so I don't fully remember.
Title: Re: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 10:50:27 pm
I might just look at the source code for mViewer, released about 12 minutes ago ;)
Title: Re: Reading/Writing Files, Listing Directories
Post by: jnesselr on December 12, 2010, 10:59:47 pm
I might just look at the source code for mViewer, released about 12 minutes ago ;)
That could work. Wait, is this for NSpire coding? Oh, I have no idea, then.
Title: Re: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 11:04:46 pm
Lol XD
Title: Re: Reading/Writing Files, Listing Directories
Post by: apcalc on December 12, 2010, 11:07:34 pm
You might want to look at the source for either bwang's bmpviewer or critor's ndshell.  Both of those programs use file listing.  I have never used this, so I won't be of any help for this (although, I better learn soon, as it will probably be used in Chip's Challenge ;))
Title: Re: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 11:08:53 pm
I would like to look at ndshell, where do I download it?  The tibank forum doesn't have a download link.
Title: Re: Reading/Writing Files, Listing Directories
Post by: apcalc on December 12, 2010, 11:10:02 pm
Here:  http://ti.bank.free.fr/index.php?mod=archives&ac=voir&id=2001
Title: Re: Reading/Writing Files, Listing Directories
Post by: SirCmpwn on December 12, 2010, 11:11:09 pm
Thank you very much!  Looking into it now.