parent
9ce43bcb4c
commit
f33e0640b3
|
@ -417,17 +417,18 @@ short chan_flush(short channel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/*
|
||||||
// Attempt to set the position of the channel cursor (if supported)
|
* Attempt to set the position of the channel cursor (if supported)
|
||||||
//
|
*
|
||||||
// Inputs:
|
* Inputs:
|
||||||
// channel = the number of the channel
|
* channel = the number of the channel
|
||||||
// position = the position of the cursor
|
* position = the position of the cursor
|
||||||
// base = whether the position is absolute or relative to the current position
|
* base = whether the position is from the beginning of the channel, relative to the current position,
|
||||||
//
|
* or relative to the end of the channel
|
||||||
// Returns:
|
*
|
||||||
// 0 = success, a negative number is an error.
|
* Returns:
|
||||||
//
|
* 0 = success, a negative number is an error.
|
||||||
|
*/
|
||||||
short chan_seek(short channel, long position, short base) {
|
short chan_seek(short channel, long position, short base) {
|
||||||
p_channel chan;
|
p_channel chan;
|
||||||
p_dev_chan cdev;
|
p_dev_chan cdev;
|
||||||
|
|
|
@ -36,8 +36,9 @@
|
||||||
#define CDEV_STAT_READABLE 0x04 // The channel has data to read (read will not block)
|
#define CDEV_STAT_READABLE 0x04 // The channel has data to read (read will not block)
|
||||||
#define CDEV_STAT_WRITABLE 0x08 // The channel can accept data (write will not block)
|
#define CDEV_STAT_WRITABLE 0x08 // The channel can accept data (write will not block)
|
||||||
|
|
||||||
#define CDEV_SEEK_ABSOLUTE 0
|
#define CDEV_SEEK_START 0 /* Seek from the start of the file */
|
||||||
#define CDEV_SEEK_RELATIVE 1
|
#define CDEV_SEEK_RELATIVE 1 /* Seek from the current position */
|
||||||
|
#define CDEV_SEEK_END 2 /* Seek from teh end of the file */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure defining a channel
|
* Structure defining a channel
|
||||||
|
@ -242,7 +243,8 @@ extern short chan_flush(short channel);
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* channel = the number of the channel
|
* channel = the number of the channel
|
||||||
* position = the position of the cursor
|
* position = the position of the cursor
|
||||||
* base = whether the position is absolute or relative to the current position
|
* base = whether the position is from the beginning of the channel, relative to the current position,
|
||||||
|
* or relative to the end of the channel
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* 0 = success, a negative number is an error.
|
* 0 = success, a negative number is an error.
|
||||||
|
|
|
@ -653,13 +653,21 @@ short fchan_seek(t_channel * chan, long position, short base) {
|
||||||
|
|
||||||
file = fchan_to_file(chan);
|
file = fchan_to_file(chan);
|
||||||
if (file) {
|
if (file) {
|
||||||
if (base == CDEV_SEEK_ABSOLUTE) {
|
if (base == CDEV_SEEK_START) {
|
||||||
|
/* Position relative to the start of the file */
|
||||||
result = f_lseek(file, position);
|
result = f_lseek(file, position);
|
||||||
return fatfs_to_foenix(result);
|
return fatfs_to_foenix(result);
|
||||||
|
|
||||||
} else if (base == CDEV_SEEK_RELATIVE) {
|
} else if (base == CDEV_SEEK_RELATIVE) {
|
||||||
|
/* Position relative to the current position */
|
||||||
long current = f_tell(file);
|
long current = f_tell(file);
|
||||||
result = f_lseek(file, current + position);
|
result = f_lseek(file, current + position);
|
||||||
return fatfs_to_foenix(result);
|
return fatfs_to_foenix(result);
|
||||||
|
|
||||||
|
} else if (base == CDEV_SEEK_END) {
|
||||||
|
/* Position relative to the end of the file */
|
||||||
|
result = f_lseek(file, f_size(file) + position);
|
||||||
|
return fatfs_to_foenix(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6558
src/foenixmcp.s68
6558
src/foenixmcp.s68
File diff suppressed because it is too large
Load diff
12513
src/mapfile
12513
src/mapfile
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue