commit
92d3a71aad
|
@ -417,17 +417,18 @@ short chan_flush(short channel) {
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Attempt to set the position of the channel cursor (if supported)
|
||||
//
|
||||
// Inputs:
|
||||
// channel = the number of the channel
|
||||
// position = the position of the cursor
|
||||
// base = whether the position is absolute or relative to the current position
|
||||
//
|
||||
// Returns:
|
||||
// 0 = success, a negative number is an error.
|
||||
//
|
||||
/*
|
||||
* Attempt to set the position of the channel cursor (if supported)
|
||||
*
|
||||
* Inputs:
|
||||
* channel = the number of the channel
|
||||
* position = the position of the cursor
|
||||
* 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.
|
||||
*/
|
||||
short chan_seek(short channel, long position, short base) {
|
||||
p_channel chan;
|
||||
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_WRITABLE 0x08 // The channel can accept data (write will not block)
|
||||
|
||||
#define CDEV_SEEK_ABSOLUTE 0
|
||||
#define CDEV_SEEK_RELATIVE 1
|
||||
#define CDEV_SEEK_START 0 /* Seek from the start of the file */
|
||||
#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
|
||||
|
@ -242,7 +243,8 @@ extern short chan_flush(short channel);
|
|||
* Inputs:
|
||||
* channel = the number of the channel
|
||||
* 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.
|
||||
|
|
|
@ -653,13 +653,21 @@ short fchan_seek(t_channel * chan, long position, short base) {
|
|||
|
||||
file = fchan_to_file(chan);
|
||||
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);
|
||||
return fatfs_to_foenix(result);
|
||||
|
||||
} else if (base == CDEV_SEEK_RELATIVE) {
|
||||
/* Position relative to the current position */
|
||||
long current = f_tell(file);
|
||||
result = f_lseek(file, current + position);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1044,7 +1052,7 @@ short fsys_elf_loader(short chan, long destination, long * start) {
|
|||
}
|
||||
progIndex++;
|
||||
}
|
||||
|
||||
|
||||
*start = header.entry;
|
||||
return 0;
|
||||
}
|
||||
|
|
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