C Language Development Kit/Functions/SetDefaultDrive

From OptiWiki

Jump to: navigation, search
Description This function sets the default drive, the drive that is choosen when no drive name is specified in the file name.

For instance when the ANSI function fopen is called as follows: fopen("test.dat","w"), a file is created on the drive that is specified with this function. When fopen is called as follows: fopen("a:test.dat","w"), the drive specified with this function is overruled, and the A-drive (the RAM disk) is choosen. When this function is never called, the internal SD card is used as default drive.

Syntax
int set_default_drive(int drive);
Arguments
int drive
drive specifies the new default drive. The following constants are defined for this:
RAM_DISK The RAM disk
INTERNAL_DISK The internal SD card
DRIVE_A The RAM disk
DRIVE_C The internal SD card
Returns The new default drive. When an invalid argument is used, the default drive is not changed, but the current default drive is returned.
Remarks The default default drive, so the drive that is used when this function is never called is the internal SD card.
Example
#include <stdio.h>
#include <stdlib.h>
#include "lib.h"
 
void main( void )
{
set_default_drive(RAM_DISK);
 
// coreleft returns the space left on the default drive.
printf("\f1: mem = %lu", coreleft());
malloc( 1000 );
printf("2: mem = %lu", coreleft());
while( 1 )
idle();
}


Views
Personal tools