mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
SCI: cleanup
svn-id: r38811
This commit is contained in:
parent
c21e6c382d
commit
376e4f86d6
@ -60,10 +60,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# define FO_BINARY "b"
|
||||
#else
|
||||
@ -79,7 +75,6 @@
|
||||
namespace Sci {
|
||||
|
||||
|
||||
|
||||
struct sci_dir_t {
|
||||
#ifdef WIN32
|
||||
long search;
|
||||
@ -132,27 +127,6 @@ FILE *sci_fopen(const char *fname, const char *mode);
|
||||
** Always refers to the cwd, cannot address subdirectories
|
||||
*/
|
||||
|
||||
int sci_open(const char *fname, int flags);
|
||||
/* Opens a file descriptor case-insensitively
|
||||
** Parameters: (const char *) fname: Name of the file to open
|
||||
** (int) flags: open(2) flags for the file
|
||||
** Returns : (int) a file descriptor of the open file,
|
||||
** or SCI_INVALID_FD on failure
|
||||
** Always refers to the cwd, cannot address subdirectories
|
||||
*/
|
||||
|
||||
char *sci_getcwd();
|
||||
/* Returns the current working directory, malloc'd.
|
||||
** Parameters: (void)
|
||||
** Returns : (char *) a malloc'd cwd, or NULL if it couldn't be determined.
|
||||
*/
|
||||
|
||||
int sci_fd_size(int fd);
|
||||
/* Returns the filesize of an open file
|
||||
** Parameters: (int) fd: File descriptor of open file
|
||||
** Returns : (int) filesize of file pointed to by fd, -1 on error
|
||||
*/
|
||||
|
||||
int sci_file_size(const char *fname);
|
||||
/* Returns the filesize of a file
|
||||
** Parameters: (const char *) fname: Name of file to get filesize of
|
||||
@ -322,42 +296,6 @@ FILE *sci_fopen(const char *fname, const char *mode) {
|
||||
return file;
|
||||
}
|
||||
|
||||
int sci_open(const char *fname, int flags) {
|
||||
int file = SCI_INVALID_FD;
|
||||
Common::String name = _fcaseseek(fname);
|
||||
if (!name.empty())
|
||||
file = open(name.c_str(), flags);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
char *sci_getcwd() {
|
||||
int size = 0;
|
||||
char *cwd = NULL;
|
||||
|
||||
while (size < 8192) {
|
||||
size += 256;
|
||||
cwd = (char*)sci_malloc(size);
|
||||
if (getcwd(cwd, size - 1))
|
||||
return cwd;
|
||||
|
||||
free(cwd);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Could not determine current working directory!\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int sci_fd_size(int fd) {
|
||||
struct stat fd_stat;
|
||||
|
||||
if (fstat(fd, &fd_stat))
|
||||
return -1;
|
||||
|
||||
return fd_stat.st_size;
|
||||
}
|
||||
|
||||
int sci_file_size(const char *fname) {
|
||||
struct stat fn_stat;
|
||||
|
||||
@ -369,7 +307,6 @@ int sci_file_size(const char *fname) {
|
||||
|
||||
|
||||
|
||||
|
||||
static int _savegame_indices_nr = -1; // means 'uninitialized'
|
||||
|
||||
static struct _savegame_index_struct {
|
||||
@ -569,16 +506,13 @@ reg_t kFGets(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
** Writes the cwd to the supplied address and returns the address in acc.
|
||||
*/
|
||||
reg_t kGetCWD(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
char *wd = sci_getcwd();
|
||||
char *targetaddr = kernel_dereference_char_pointer(s, argv[0], 0);
|
||||
|
||||
strncpy(targetaddr, wd, MAX_SAVE_DIR_SIZE - 1);
|
||||
getcwd(targetaddr, MAX_SAVE_DIR_SIZE - 1);
|
||||
|
||||
targetaddr[MAX_SAVE_DIR_SIZE - 1] = 0; // Terminate
|
||||
debug(3, "kGetCWD() -> %s", targetaddr);
|
||||
|
||||
SCIkdebug(SCIkFILE, "Copying cwd='%s'(%d chars) to %p", wd, strlen(wd), targetaddr);
|
||||
|
||||
free(wd);
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user