This wiki is out of date, use the continuation of this wiki instead

Fopen

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:33, 28 May 2007 (edit)
Woody (Talk | contribs)

← Previous diff
Current revision (14:03, 26 June 2007) (edit) (undo)
Sandman (Talk | contribs)
m
 
(2 intermediate revisions not shown.)
Line 3: Line 3:
==Definition== ==Definition==
-'''INT''' fopen ( <'''STRING''' path> , <'''INT''' mode> )+'''INT''' fopen ( <'''STRING''' filename> , <'''INT''' mode> )
Opens a file on the hard drive for reading or writing. Opens a file on the hard drive for reading or writing.
Line 9: Line 9:
== Parameters == == Parameters ==
{| {|
-| '''STRING''' path || - The path to the file you wish to open for reading/writing.+| '''STRING''' filename || - The filename of the file you wish to open (including extension and possible path).
|- |-
| '''INT''' mode || - The mode with which to access the file (see [[Readwrite_modes]]). | '''INT''' mode || - The mode with which to access the file (see [[Readwrite_modes]]).
Line 15: Line 15:
== Returns == == Returns ==
-'''INT''' : Handle+'''INT''' : [[FileHandle]]
{| {|
| 0 || - Could not load. | 0 || - Could not load.
|- |-
-| >0 || - The identifier of the file now opened for reading/writing.+| !0 || - The identifier of the file now opened for reading/writing.
|} |}
Line 26: Line 26:
Process loadthing(STRING loadpath); Process loadthing(STRING loadpath);
Private Private
- handle; // handle for the loaded file + int handle; // handle for the loaded file
- druppels; // here's where the loaded data go+ int druppels; // here's where the loaded data go
- +
Begin Begin
Line 34: Line 33:
fread(handle,druppels); // reads from the file and puts the data in druppels fread(handle,druppels); // reads from the file and puts the data in druppels
fclose(handle); // zipping up after business is done fclose(handle); // zipping up after business is done
- + write(0,0,0,0,druppels); // shows the value of druppels
- write_int(0,160,100,4,&druppels); // let's see what we got here+
End End
- 
</pre> </pre>
-Used in example: [[fread]], [[fclose]], [[write_int]]+Used in example: [[fread]](), [[fclose]](), [[write]]()

Current revision


Contents

[edit] Definition

INT fopen ( <STRING filename> , <INT mode> )

Opens a file on the hard drive for reading or writing.

[edit] Parameters

STRING filename - The filename of the file you wish to open (including extension and possible path).
INT mode - The mode with which to access the file (see Readwrite_modes).

[edit] Returns

INT : FileHandle

0 - Could not load.
 !0 - The identifier of the file now opened for reading/writing.

[edit] Example

Process loadthing(STRING loadpath);
Private
    int handle;   // handle for the loaded file 
    int druppels; // here's where the loaded data go
Begin

    handle=fopen(loadpath,O_READ); // opens the file in reading mode
    fread(handle,druppels);        // reads from the file and puts the data in druppels
    fclose(handle);                // zipping up after business is done
    write(0,0,0,0,druppels);       // shows the value of druppels

End

Used in example: fread(), fclose(), write()

Personal tools