mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-05-09 20:01:19 +08:00
remove PHYSFS support
This commit is contained in:
parent
6c33ba4ba0
commit
f1e4e69b0c
@ -74,9 +74,6 @@
|
|||||||
/* Define to 1 if you have the mprotect function */
|
/* Define to 1 if you have the mprotect function */
|
||||||
#undef C_HAVE_MPROTECT
|
#undef C_HAVE_MPROTECT
|
||||||
|
|
||||||
/* Define to 1 if you have physfs library */
|
|
||||||
#undef C_HAVE_PHYSFS
|
|
||||||
|
|
||||||
/* Define to 1 to enable heavy debugging, also have to enable C_DEBUG */
|
/* Define to 1 to enable heavy debugging, also have to enable C_DEBUG */
|
||||||
#undef C_HEAVY_DEBUG
|
#undef C_HEAVY_DEBUG
|
||||||
|
|
||||||
|
50
configure
vendored
50
configure
vendored
@ -7619,56 +7619,6 @@ fi
|
|||||||
rm -f core conftest.err conftest.$ac_objext \
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
conftest$ac_exeext conftest.$ac_ext
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
|
||||||
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PHYSFS_init in -lphysfs" >&5
|
|
||||||
$as_echo_n "checking for PHYSFS_init in -lphysfs... " >&6; }
|
|
||||||
if ${ac_cv_lib_physfs_PHYSFS_init+:} false; then :
|
|
||||||
$as_echo_n "(cached) " >&6
|
|
||||||
else
|
|
||||||
ac_check_lib_save_LIBS=$LIBS
|
|
||||||
LIBS="-lphysfs $LIBS"
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
/* Override any GCC internal prototype to avoid an error.
|
|
||||||
Use char because int might match the return type of a GCC
|
|
||||||
builtin and then its argument prototype would still apply. */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
#endif
|
|
||||||
char PHYSFS_init ();
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
return PHYSFS_init ();
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_link "$LINENO"; then :
|
|
||||||
ac_cv_lib_physfs_PHYSFS_init=yes
|
|
||||||
else
|
|
||||||
ac_cv_lib_physfs_PHYSFS_init=no
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext \
|
|
||||||
conftest$ac_exeext conftest.$ac_ext
|
|
||||||
LIBS=$ac_check_lib_save_LIBS
|
|
||||||
fi
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_physfs_PHYSFS_init" >&5
|
|
||||||
$as_echo "$ac_cv_lib_physfs_PHYSFS_init" >&6; }
|
|
||||||
if test "x$ac_cv_lib_physfs_PHYSFS_init" = xyes; then :
|
|
||||||
have_PHYSFS_init=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test x$have_PHYSFS_init = xyes ; then
|
|
||||||
$as_echo "#define C_HAVE_PHYSFS 1" >>confdefs.h
|
|
||||||
|
|
||||||
LIBS="$LIBS -lphysfs -lz"
|
|
||||||
else
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't find PHYSFS_init" >&5
|
|
||||||
$as_echo "$as_me: WARNING: Can't find PHYSFS_init" >&2;}
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$host" in
|
case "$host" in
|
||||||
*-*-cygwin* | *-*-mingw32*)
|
*-*-cygwin* | *-*-mingw32*)
|
||||||
LIBS="$LIBS -lwinmm"
|
LIBS="$LIBS -lwinmm"
|
||||||
|
@ -489,15 +489,6 @@ int main(int argc,char * argv[]) {
|
|||||||
};
|
};
|
||||||
])],AC_MSG_RESULT(yes);AC_DEFINE(C_SET_PRIORITY,1),AC_MSG_RESULT(no))
|
])],AC_MSG_RESULT(yes);AC_DEFINE(C_SET_PRIORITY,1),AC_MSG_RESULT(no))
|
||||||
|
|
||||||
AH_TEMPLATE(C_HAVE_PHYSFS,[Define to 1 if you have physfs library])
|
|
||||||
AC_CHECK_LIB(physfs, PHYSFS_init, have_PHYSFS_init=yes,,)
|
|
||||||
if test x$have_PHYSFS_init = xyes ; then
|
|
||||||
AC_DEFINE(C_HAVE_PHYSFS,1)
|
|
||||||
LIBS="$LIBS -lphysfs -lz"
|
|
||||||
else
|
|
||||||
AC_MSG_WARN([Can't find PHYSFS_init])
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl Some target detection and actions for them
|
dnl Some target detection and actions for them
|
||||||
case "$host" in
|
case "$host" in
|
||||||
*-*-cygwin* | *-*-mingw32*)
|
*-*-cygwin* | *-*-mingw32*)
|
||||||
|
@ -30,7 +30,6 @@ void BrowseFolder( char drive , std::string drive_type );
|
|||||||
void Mount_Img(char drive, std::string realpath);
|
void Mount_Img(char drive, std::string realpath);
|
||||||
void Mount_Img_Floppy(char drive, std::string realpath);
|
void Mount_Img_Floppy(char drive, std::string realpath);
|
||||||
void Mount_Img_HDD(char drive, std::string realpath);
|
void Mount_Img_HDD(char drive, std::string realpath);
|
||||||
void Mount_Zip(char drive, std::string temp_line);
|
|
||||||
void DOSBox_SetMenu(void);
|
void DOSBox_SetMenu(void);
|
||||||
void DOSBox_NoMenu(void);
|
void DOSBox_NoMenu(void);
|
||||||
void DOSBox_RefreshMenu(void);
|
void DOSBox_RefreshMenu(void);
|
||||||
|
@ -356,24 +356,12 @@ public:
|
|||||||
OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L);
|
OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L);
|
||||||
DosClose(cdrom_fd);
|
DosClose(cdrom_fd);
|
||||||
if (rc != NO_ERROR && rc != ERROR_NOT_READY) {
|
if (rc != NO_ERROR && rc != ERROR_NOT_READY) {
|
||||||
#if C_HAVE_PHYSFS
|
|
||||||
// Make it a physfs then...
|
|
||||||
is_physfs = true;
|
|
||||||
temp_line.insert(0, 1, ':');
|
|
||||||
#else
|
|
||||||
WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str());
|
WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str());
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#if C_HAVE_PHYSFS
|
|
||||||
// Make it a physfs then...
|
|
||||||
is_physfs = true;
|
|
||||||
temp_line.insert(0, 1, ':');
|
|
||||||
#else
|
#else
|
||||||
WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str());
|
WriteOut(MSG_Get("PROGRAM_MOUNT_ERROR_2"),temp_line.c_str());
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -413,11 +401,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (is_physfs) {
|
if (is_physfs) {
|
||||||
#if C_HAVE_PHYSFS
|
|
||||||
newdrive = new physfscdromDrive(drive,temp_line.c_str(),sizes[0],bit8size,sizes[2],0,mediaid,error);
|
|
||||||
#else
|
|
||||||
LOG_MSG("ERROR:This build does not support physfs");
|
LOG_MSG("ERROR:This build does not support physfs");
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
newdrive = new cdromDrive(drive,temp_line.c_str(),sizes[0],bit8size,sizes[2],0,mediaid,error);
|
newdrive = new cdromDrive(drive,temp_line.c_str(),sizes[0],bit8size,sizes[2],0,mediaid,error);
|
||||||
}
|
}
|
||||||
@ -445,11 +429,7 @@ public:
|
|||||||
if(temp_line == "/") WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_OTHER"));
|
if(temp_line == "/") WriteOut(MSG_Get("PROGRAM_MOUNT_WARNING_OTHER"));
|
||||||
#endif
|
#endif
|
||||||
if (is_physfs) {
|
if (is_physfs) {
|
||||||
#if C_HAVE_PHYSFS
|
|
||||||
newdrive=new physfsDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid);
|
|
||||||
#else
|
|
||||||
LOG_MSG("ERROR:This build does not support physfs");
|
LOG_MSG("ERROR:This build does not support physfs");
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
newdrive=new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid);
|
newdrive=new localDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid);
|
||||||
}
|
}
|
||||||
|
@ -1,841 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2002-2013 The DOSBox Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#include "dosbox.h"
|
|
||||||
|
|
||||||
#if C_HAVE_PHYSFS
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <physfs.h>
|
|
||||||
#include "dos_inc.h"
|
|
||||||
#include "drives.h"
|
|
||||||
#include "support.h"
|
|
||||||
#include "cross.h"
|
|
||||||
|
|
||||||
/* yuck. Hopefully, later physfs versions improve things */
|
|
||||||
/* The hackishness level is quite low, but to get perfect, here is my personal wishlist for PHYSFS:
|
|
||||||
- mounting zip files at arbitrary locations (already in CVS, I think)
|
|
||||||
- rename support
|
|
||||||
- a better API for stat() infos
|
|
||||||
- more stdio-like API for seek, open and truncate
|
|
||||||
- perhaps a ramdisk as write dir?
|
|
||||||
*/
|
|
||||||
PHYSFS_sint64 PHYSFS_fileLength(const char *name) {
|
|
||||||
PHYSFS_file *f = PHYSFS_openRead(name);
|
|
||||||
if (f == NULL) return 0;
|
|
||||||
PHYSFS_sint64 size = PHYSFS_fileLength(f);
|
|
||||||
PHYSFS_close(f);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
class physfsFile : public DOS_File {
|
|
||||||
public:
|
|
||||||
physfsFile(const char* name, PHYSFS_file * handle,Bit16u devinfo, const char* physname, bool write);
|
|
||||||
bool Read(Bit8u * data,Bit16u * size);
|
|
||||||
bool Write(Bit8u * data,Bit16u * size);
|
|
||||||
bool Seek(Bit32u * pos,Bit32u type);
|
|
||||||
bool prepareRead();
|
|
||||||
bool prepareWrite();
|
|
||||||
bool Close();
|
|
||||||
Bit16u GetInformation(void);
|
|
||||||
bool UpdateDateTimeFromHost(void);
|
|
||||||
private:
|
|
||||||
PHYSFS_file * fhandle;
|
|
||||||
enum { READ,WRITE } last_action;
|
|
||||||
Bit16u info;
|
|
||||||
char pname[CROSS_LEN];
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Need to strip "/.." components and transform '\\' to '/' for physfs */
|
|
||||||
static char *normalize(char * name, const char *basedir) {
|
|
||||||
int last = strlen(name)-1;
|
|
||||||
strreplace(name,'\\','/');
|
|
||||||
while (last >= 0 && name[last] == '/') name[last--] = 0;
|
|
||||||
if (last > 0 && name[last] == '.' && name[last-1] == '/') name[last-1] = 0;
|
|
||||||
if (last > 1 && name[last] == '.' && name[last-1] == '.' && name[last-2] == '/') {
|
|
||||||
name[last-2] = 0;
|
|
||||||
char *slash = strrchr(name,'/');
|
|
||||||
if (slash) *slash = 0;
|
|
||||||
}
|
|
||||||
if (strlen(basedir) > strlen(name)) { strcpy(name,basedir); strreplace(name,'\\','/'); }
|
|
||||||
last = strlen(name)-1;
|
|
||||||
while (last >= 0 && name[last] == '/') name[last--] = 0;
|
|
||||||
if (name[0] == 0) name[0] = '/';
|
|
||||||
//LOG_MSG("File access: %s",name);
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::FileCreate(DOS_File * * file,const char * name,Bit16u attributes) {
|
|
||||||
char newname[CROSS_LEN];
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.ExpandName(newname);
|
|
||||||
normalize(newname,basedir);
|
|
||||||
|
|
||||||
/* Test if file exists, don't add to dirCache then */
|
|
||||||
bool existing_file=PHYSFS_exists(newname);
|
|
||||||
|
|
||||||
char *slash = strrchr(newname,'/');
|
|
||||||
if (slash && slash != newname) {
|
|
||||||
char file[CROSS_LEN];
|
|
||||||
*slash = 0;
|
|
||||||
if (!PHYSFS_isDirectory(newname)) return false;
|
|
||||||
PHYSFS_mkdir(newname);
|
|
||||||
*slash = '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
PHYSFS_file * hand=PHYSFS_openWrite(newname);
|
|
||||||
if (!hand){
|
|
||||||
LOG_MSG("Warning: file creation failed: %s (%s)",newname,PHYSFS_getLastError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make the 16 bit device information */
|
|
||||||
*file=new physfsFile(name,hand,0x202,newname,true);
|
|
||||||
(*file)->flags=OPEN_READWRITE;
|
|
||||||
if(!existing_file) {
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.AddEntry(newname, true);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::FileOpen(DOS_File * * file,const char * name,Bit32u flags) {
|
|
||||||
char newname[CROSS_LEN];
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.ExpandName(newname);
|
|
||||||
normalize(newname,basedir);
|
|
||||||
|
|
||||||
PHYSFS_file * hand;
|
|
||||||
|
|
||||||
if (!PHYSFS_exists(newname)) return false;
|
|
||||||
if ((flags&0xf) == OPEN_READ) {
|
|
||||||
hand = PHYSFS_openRead(newname);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* open for reading, deal with writing later */
|
|
||||||
hand = PHYSFS_openRead(newname);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hand) {
|
|
||||||
if((flags&0xf) != OPEN_READ) {
|
|
||||||
PHYSFS_file *hmm = PHYSFS_openRead(newname);
|
|
||||||
if (hmm) {
|
|
||||||
PHYSFS_close(hmm);
|
|
||||||
LOG_MSG("Warning: file %s exists and failed to open in write mode.\nPlease mount a write directory (see docs).",newname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*file=new physfsFile(name,hand,0x202,newname,false);
|
|
||||||
(*file)->flags=flags; //for the inheritance flag and maybe check for others.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::FileUnlink(const char * name) {
|
|
||||||
char newname[CROSS_LEN];
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.ExpandName(newname);
|
|
||||||
normalize(newname,basedir);
|
|
||||||
if (PHYSFS_delete(newname)) {
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.DeleteEntry(newname);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool physfsDrive::FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst) {
|
|
||||||
|
|
||||||
char tempDir[CROSS_LEN];
|
|
||||||
strcpy(tempDir,basedir);
|
|
||||||
strcat(tempDir,_dir);
|
|
||||||
CROSS_FILENAME(tempDir);
|
|
||||||
|
|
||||||
char end[2]={CROSS_FILESPLIT,0};
|
|
||||||
if (tempDir[strlen(tempDir)-1]!=CROSS_FILESPLIT) strcat(tempDir,end);
|
|
||||||
|
|
||||||
Bit16u id;
|
|
||||||
if (!dirCache.FindFirst(tempDir,id))
|
|
||||||
{
|
|
||||||
DOS_SetError(DOSERR_PATH_NOT_FOUND);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
strcpy(srchInfo[id].srch_dir,tempDir);
|
|
||||||
dta.SetDirID(id);
|
|
||||||
|
|
||||||
Bit8u sAttr;
|
|
||||||
dta.GetSearchParams(sAttr,tempDir);
|
|
||||||
|
|
||||||
if (sAttr == DOS_ATTR_VOLUME) {
|
|
||||||
if ( strcmp(dirCache.GetLabel(), "") == 0 ) {
|
|
||||||
LOG(LOG_DOSMISC,LOG_ERROR)("DRIVELABEL REQUESTED: none present, returned NOLABEL");
|
|
||||||
dta.SetResult("NO_LABEL",0,0,0,DOS_ATTR_VOLUME);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME);
|
|
||||||
return true;
|
|
||||||
} else if ((sAttr & DOS_ATTR_VOLUME) && (*_dir == 0) && !fcb_findfirst) {
|
|
||||||
//should check for a valid leading directory instead of 0
|
|
||||||
//exists==true if the volume label matches the searchmask and the path is valid
|
|
||||||
if ( strcmp(dirCache.GetLabel(), "") == 0 ) {
|
|
||||||
LOG(LOG_DOSMISC,LOG_ERROR)("DRIVELABEL REQUESTED: none present, returned NOLABEL");
|
|
||||||
dta.SetResult("NO_LABEL",0,0,0,DOS_ATTR_VOLUME);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (WildFileCmp(dirCache.GetLabel(),tempDir)) {
|
|
||||||
dta.SetResult(dirCache.GetLabel(),0,0,0,DOS_ATTR_VOLUME);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FindNext(dta);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::FindNext(DOS_DTA & dta) {
|
|
||||||
|
|
||||||
char * dir_ent;
|
|
||||||
char full_name[CROSS_LEN];
|
|
||||||
|
|
||||||
Bit8u srch_attr;char srch_pattern[DOS_NAMELENGTH_ASCII];
|
|
||||||
Bit8u find_attr;
|
|
||||||
|
|
||||||
dta.GetSearchParams(srch_attr,srch_pattern);
|
|
||||||
|
|
||||||
Bitu id = dta.GetDirID();
|
|
||||||
|
|
||||||
again:
|
|
||||||
if (!dirCache.FindNext(id,dir_ent)) {
|
|
||||||
DOS_SetError(DOSERR_NO_MORE_FILES);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(!WildFileCmp(dir_ent,srch_pattern)) goto again;
|
|
||||||
|
|
||||||
char find_name[DOS_NAMELENGTH_ASCII];Bit16u find_date,find_time;Bit32u find_size;
|
|
||||||
if(strlen(dir_ent)<DOS_NAMELENGTH_ASCII){
|
|
||||||
strcpy(find_name,dir_ent);
|
|
||||||
upcase(find_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(full_name,srchInfo[id].srch_dir);
|
|
||||||
strcat(full_name,dir_ent);
|
|
||||||
dirCache.ExpandName(full_name);
|
|
||||||
normalize(full_name,basedir);
|
|
||||||
|
|
||||||
if (PHYSFS_isDirectory(full_name)) find_attr=DOS_ATTR_DIRECTORY|DOS_ATTR_ARCHIVE;
|
|
||||||
else find_attr=DOS_ATTR_ARCHIVE;
|
|
||||||
if (~srch_attr & find_attr & (DOS_ATTR_DIRECTORY | DOS_ATTR_HIDDEN | DOS_ATTR_SYSTEM)) goto again;
|
|
||||||
|
|
||||||
/*file is okay, setup everything to be copied in DTA Block */
|
|
||||||
find_size=(Bit32u)PHYSFS_fileLength(full_name);
|
|
||||||
time_t mytime = PHYSFS_getLastModTime(full_name);
|
|
||||||
struct tm *time;
|
|
||||||
if((time=localtime(&mytime))!=0){
|
|
||||||
find_date=DOS_PackDate((Bit16u)(time->tm_year+1900),(Bit16u)(time->tm_mon+1),(Bit16u)time->tm_mday);
|
|
||||||
find_time=DOS_PackTime((Bit16u)time->tm_hour,(Bit16u)time->tm_min,(Bit16u)time->tm_sec);
|
|
||||||
} else {
|
|
||||||
find_time=6;
|
|
||||||
find_date=4;
|
|
||||||
}
|
|
||||||
dta.SetResult(find_name,find_size,find_date,find_time,find_attr);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::GetFileAttr(const char * name,Bit16u * attr) {
|
|
||||||
char newname[CROSS_LEN];
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.ExpandName(newname);
|
|
||||||
normalize(newname,basedir);
|
|
||||||
char *last = strrchr(newname,'/');
|
|
||||||
if (last == NULL) last = newname-1;
|
|
||||||
|
|
||||||
*attr = 0;
|
|
||||||
if (!PHYSFS_exists(newname)) return false;
|
|
||||||
*attr=DOS_ATTR_ARCHIVE;
|
|
||||||
if (PHYSFS_isDirectory(newname)) *attr|=DOS_ATTR_DIRECTORY;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::MakeDir(const char * dir) {
|
|
||||||
char newdir[CROSS_LEN];
|
|
||||||
strcpy(newdir,basedir);
|
|
||||||
strcat(newdir,dir);
|
|
||||||
CROSS_FILENAME(newdir);
|
|
||||||
dirCache.ExpandName(newdir);
|
|
||||||
normalize(newdir,basedir);
|
|
||||||
if (PHYSFS_mkdir(newdir)) {
|
|
||||||
CROSS_FILENAME(newdir);
|
|
||||||
dirCache.CacheOut(newdir,true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::RemoveDir(const char * dir) {
|
|
||||||
char newdir[CROSS_LEN];
|
|
||||||
strcpy(newdir,basedir);
|
|
||||||
strcat(newdir,dir);
|
|
||||||
CROSS_FILENAME(newdir);
|
|
||||||
dirCache.ExpandName(newdir);
|
|
||||||
normalize(newdir,basedir);
|
|
||||||
if (PHYSFS_isDirectory(newdir) && PHYSFS_delete(newdir)) {
|
|
||||||
CROSS_FILENAME(newdir);
|
|
||||||
dirCache.DeleteEntry(newdir,true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::TestDir(const char * dir) {
|
|
||||||
char newdir[CROSS_LEN];
|
|
||||||
strcpy(newdir,basedir);
|
|
||||||
strcat(newdir,dir);
|
|
||||||
CROSS_FILENAME(newdir);
|
|
||||||
dirCache.ExpandName(newdir);
|
|
||||||
normalize(newdir,basedir);
|
|
||||||
return (PHYSFS_isDirectory(newdir));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::Rename(const char * oldname,const char * newname) {
|
|
||||||
char newold[CROSS_LEN];
|
|
||||||
strcpy(newold,basedir);
|
|
||||||
strcat(newold,oldname);
|
|
||||||
CROSS_FILENAME(newold);
|
|
||||||
dirCache.ExpandName(newold);
|
|
||||||
normalize(newold,basedir);
|
|
||||||
|
|
||||||
char newnew[CROSS_LEN];
|
|
||||||
strcpy(newnew,basedir);
|
|
||||||
strcat(newnew,newname);
|
|
||||||
CROSS_FILENAME(newnew);
|
|
||||||
dirCache.ExpandName(newnew);
|
|
||||||
normalize(newnew,basedir);
|
|
||||||
/* yuck. physfs doesn't have "rename". */
|
|
||||||
LOG_MSG("PHYSFS TODO: rename not yet implemented (%s -> %s)",newold,newnew);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::AllocationInfo(Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters,Bit16u * _free_clusters) {
|
|
||||||
/* Always report 100 mb free should be enough */
|
|
||||||
/* Total size is always 1 gb */
|
|
||||||
*_bytes_sector=allocation.bytes_sector;
|
|
||||||
*_sectors_cluster=allocation.sectors_cluster;
|
|
||||||
*_total_clusters=allocation.total_clusters;
|
|
||||||
*_free_clusters=allocation.free_clusters;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::FileExists(const char* name) {
|
|
||||||
char newname[CROSS_LEN];
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.ExpandName(newname);
|
|
||||||
normalize(newname,basedir);
|
|
||||||
return PHYSFS_exists(newname) && !PHYSFS_isDirectory(newname);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::FileStat(const char* name, FileStat_Block * const stat_block) {
|
|
||||||
char newname[CROSS_LEN];
|
|
||||||
strcpy(newname,basedir);
|
|
||||||
strcat(newname,name);
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
dirCache.ExpandName(newname);
|
|
||||||
normalize(newname,basedir);
|
|
||||||
time_t mytime = PHYSFS_getLastModTime(newname);
|
|
||||||
/* Convert the stat to a FileStat */
|
|
||||||
struct tm *time;
|
|
||||||
if((time=localtime(&mytime))!=0) {
|
|
||||||
stat_block->time=DOS_PackTime((Bit16u)time->tm_hour,(Bit16u)time->tm_min,(Bit16u)time->tm_sec);
|
|
||||||
stat_block->date=DOS_PackDate((Bit16u)(time->tm_year+1900),(Bit16u)(time->tm_mon+1),(Bit16u)time->tm_mday);
|
|
||||||
} else {
|
|
||||||
stat_block->time=DOS_PackTime(0,0,0);
|
|
||||||
stat_block->date=DOS_PackDate(1980,1,1);
|
|
||||||
}
|
|
||||||
stat_block->size=(Bit32u)PHYSFS_fileLength(newname);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Bit8u physfsDrive::GetMediaByte(void) {
|
|
||||||
return allocation.mediaid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::isRemote(void) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::isRemovable(void) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct opendirinfo {
|
|
||||||
char **files;
|
|
||||||
int pos;
|
|
||||||
};
|
|
||||||
/* helper functions for drive cache */
|
|
||||||
bool physfsDrive::isdir(const char *name) {
|
|
||||||
char myname[CROSS_LEN];
|
|
||||||
strcpy(myname,name);
|
|
||||||
normalize(myname,basedir);
|
|
||||||
return PHYSFS_isDirectory(myname);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *physfsDrive::opendir(const char *name) {
|
|
||||||
char myname[CROSS_LEN];
|
|
||||||
strcpy(myname,name);
|
|
||||||
normalize(myname,basedir);
|
|
||||||
if (!PHYSFS_isDirectory(myname)) return false;
|
|
||||||
|
|
||||||
struct opendirinfo *oinfo = (struct opendirinfo *)malloc(sizeof(struct opendirinfo));
|
|
||||||
oinfo->files = PHYSFS_enumerateFiles(myname);
|
|
||||||
if (oinfo->files == NULL) {
|
|
||||||
LOG_MSG("PHYSFS: nothing found for %s (%s)",myname,PHYSFS_getLastError());
|
|
||||||
free(oinfo);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
oinfo->pos = (myname[1] == 0?0:-2);
|
|
||||||
return (void *)oinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void physfsDrive::closedir(void *handle) {
|
|
||||||
struct opendirinfo *oinfo = (struct opendirinfo *)handle;
|
|
||||||
if (handle == NULL) return;
|
|
||||||
if (oinfo->files != NULL) PHYSFS_freeList(oinfo->files);
|
|
||||||
free(oinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::read_directory_first(void* dirp, char* entry_name, bool& is_directory) {
|
|
||||||
return read_directory_next(dirp, entry_name, is_directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsDrive::read_directory_next(void* dirp, char* entry_name, bool& is_directory) {
|
|
||||||
struct opendirinfo *oinfo = (struct opendirinfo *)dirp;
|
|
||||||
if (!oinfo) return false;
|
|
||||||
if (oinfo->pos == -2) {
|
|
||||||
oinfo->pos++;
|
|
||||||
safe_strncpy(entry_name,".",CROSS_LEN);
|
|
||||||
is_directory = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (oinfo->pos == -1) {
|
|
||||||
oinfo->pos++;
|
|
||||||
safe_strncpy(entry_name,"..",CROSS_LEN);
|
|
||||||
is_directory = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!oinfo->files || !oinfo->files[oinfo->pos]) return false;
|
|
||||||
safe_strncpy(entry_name,oinfo->files[oinfo->pos++],CROSS_LEN);
|
|
||||||
is_directory = isdir(entry_name);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern std::string capturedir;
|
|
||||||
static Bit8u physfs_used = 0;
|
|
||||||
physfsDrive::physfsDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid)
|
|
||||||
:localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid) {
|
|
||||||
|
|
||||||
char newname[CROSS_LEN+1];
|
|
||||||
|
|
||||||
/* No writedir given, use capture directory */
|
|
||||||
if(startdir[0] == ':') {
|
|
||||||
strcpy(newname,capturedir.c_str());
|
|
||||||
strcat(newname,startdir);
|
|
||||||
} else {
|
|
||||||
strcpy(newname,startdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
CROSS_FILENAME(newname);
|
|
||||||
if (!physfs_used) {
|
|
||||||
PHYSFS_init("");
|
|
||||||
PHYSFS_permitSymbolicLinks(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
physfs_used++;
|
|
||||||
char *lastdir = newname;
|
|
||||||
char *dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':');
|
|
||||||
while (dir) {
|
|
||||||
*dir++ = 0;
|
|
||||||
if((lastdir == newname) && !strchr(dir+(((dir[0]|0x20) >= 'a' && (dir[0]|0x20) <= 'z')?2:0),':')) {
|
|
||||||
// If the first parameter is a directory, the next one has to be the archive file,
|
|
||||||
// do not confuse it with basedir if trailing : is not there!
|
|
||||||
int tmp = strlen(dir)-1;
|
|
||||||
dir[tmp++] = ':';
|
|
||||||
dir[tmp++] = CROSS_FILESPLIT;
|
|
||||||
dir[tmp] = '\0';
|
|
||||||
}
|
|
||||||
if (*lastdir && PHYSFS_addToSearchPath(lastdir,true) == 0) {
|
|
||||||
LOG_MSG("PHYSFS couldn't add '%s': %s",lastdir,PHYSFS_getLastError());
|
|
||||||
}
|
|
||||||
lastdir = dir;
|
|
||||||
dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':');
|
|
||||||
}
|
|
||||||
const char *oldwrite = PHYSFS_getWriteDir();
|
|
||||||
if (oldwrite) oldwrite = strdup(oldwrite);
|
|
||||||
if (!PHYSFS_setWriteDir(newname)) {
|
|
||||||
if (!oldwrite)
|
|
||||||
LOG_MSG("PHYSFS can't use '%s' for writing, you might encounter problems",newname);
|
|
||||||
else
|
|
||||||
PHYSFS_setWriteDir(oldwrite);
|
|
||||||
}
|
|
||||||
if (oldwrite) free((char *)oldwrite);
|
|
||||||
|
|
||||||
strcpy(basedir,lastdir);
|
|
||||||
|
|
||||||
allocation.bytes_sector=_bytes_sector;
|
|
||||||
allocation.sectors_cluster=_sectors_cluster;
|
|
||||||
allocation.total_clusters=_total_clusters;
|
|
||||||
allocation.free_clusters=_free_clusters;
|
|
||||||
allocation.mediaid=_mediaid;
|
|
||||||
|
|
||||||
dirCache.SetBaseDir(basedir, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
physfsDrive::~physfsDrive(void) {
|
|
||||||
if(!physfs_used) {
|
|
||||||
LOG_MSG("PHYSFS invalid reference count!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
physfs_used--;
|
|
||||||
if(!physfs_used) {
|
|
||||||
LOG_MSG("PHYSFS calling PHYSFS_deinit()");
|
|
||||||
PHYSFS_deinit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *physfsDrive::GetInfo() {
|
|
||||||
char **files = PHYSFS_getSearchPath(), **list = files;
|
|
||||||
sprintf(info,"PHYSFS directory %s in ",basedir);
|
|
||||||
while (*files != NULL) {
|
|
||||||
strcat(info,*files++);
|
|
||||||
strcat(info,", ");
|
|
||||||
}
|
|
||||||
if (PHYSFS_getWriteDir() != NULL) {
|
|
||||||
strcat(info,"writing to ");
|
|
||||||
strcat(info,PHYSFS_getWriteDir());
|
|
||||||
} else {
|
|
||||||
strcat(info,"read-only");
|
|
||||||
}
|
|
||||||
PHYSFS_freeList(list);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool physfsFile::Read(Bit8u * data,Bit16u * size) {
|
|
||||||
if ((this->flags & 0xf) == OPEN_WRITE) { // check if file opened in write-only mode
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (last_action==WRITE) prepareRead();
|
|
||||||
last_action=READ;
|
|
||||||
PHYSFS_sint64 mysize = PHYSFS_read(fhandle,data,1,(PHYSFS_uint64)*size);
|
|
||||||
//LOG_MSG("Read %i bytes (wanted %i) at %i of %s (%s)",(int)mysize,(int)*size,(int)PHYSFS_tell(fhandle),name,PHYSFS_getLastError());
|
|
||||||
*size = (Bit16u)mysize;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsFile::Write(Bit8u * data,Bit16u * size) {
|
|
||||||
if ((this->flags & 0xf) == OPEN_READ) { // check if file opened in read-only mode
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (last_action==READ) prepareWrite();
|
|
||||||
last_action=WRITE;
|
|
||||||
if (*size==0) {
|
|
||||||
if (PHYSFS_tell(fhandle) == 0) {
|
|
||||||
PHYSFS_close(PHYSFS_openWrite(pname));
|
|
||||||
//LOG_MSG("Truncate %s (%s)",name,PHYSFS_getLastError());
|
|
||||||
} else {
|
|
||||||
LOG_MSG("PHYSFS TODO: truncate not yet implemented (%s at %i)",pname,PHYSFS_tell(fhandle));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PHYSFS_sint64 mysize = PHYSFS_write(fhandle,data,1,(PHYSFS_uint64)*size);
|
|
||||||
//LOG_MSG("Wrote %i bytes (wanted %i) at %i of %s (%s)",(int)mysize,(int)*size,(int)PHYSFS_tell(fhandle),name,PHYSFS_getLastError());
|
|
||||||
*size = (Bit16u)mysize;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool physfsFile::Seek(Bit32u * pos,Bit32u type) {
|
|
||||||
PHYSFS_sint64 mypos = (Bit32s)*pos;
|
|
||||||
switch (type) {
|
|
||||||
case DOS_SEEK_SET:break;
|
|
||||||
case DOS_SEEK_CUR:mypos += PHYSFS_tell(fhandle); break;
|
|
||||||
case DOS_SEEK_END:mypos += PHYSFS_fileLength(fhandle);-mypos; break;
|
|
||||||
default:
|
|
||||||
//TODO Give some doserrorcode;
|
|
||||||
return false;//ERROR
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PHYSFS_seek(fhandle,mypos)) {
|
|
||||||
// Out of file range, pretend everythings ok
|
|
||||||
// and move file pointer top end of file... ?! (Black Thorne)
|
|
||||||
PHYSFS_seek(fhandle,PHYSFS_fileLength(fhandle));
|
|
||||||
};
|
|
||||||
//LOG_MSG("Seek to %i (%i at %x) of %s (%s)",(int)mypos,(int)*pos,type,name,PHYSFS_getLastError());
|
|
||||||
|
|
||||||
*pos=(Bit32u)PHYSFS_tell(fhandle);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsFile::prepareRead() {
|
|
||||||
PHYSFS_uint64 pos = PHYSFS_tell(fhandle);
|
|
||||||
PHYSFS_close(fhandle);
|
|
||||||
fhandle = PHYSFS_openRead(pname);
|
|
||||||
PHYSFS_seek(fhandle, pos);
|
|
||||||
return true; //LOG_MSG("Goto read (%s at %i)",pname,PHYSFS_tell(fhandle));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool physfsFile::prepareWrite() {
|
|
||||||
const char *wdir = PHYSFS_getWriteDir();
|
|
||||||
if (wdir == NULL) {
|
|
||||||
LOG_MSG("PHYSFS could not fulfill write request: no write directory set.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//LOG_MSG("Goto write (%s at %i)",pname,PHYSFS_tell(fhandle));
|
|
||||||
const char *fdir = PHYSFS_getRealDir(pname);
|
|
||||||
PHYSFS_uint64 pos = PHYSFS_tell(fhandle);
|
|
||||||
char *slash = strrchr(pname,'/');
|
|
||||||
if (slash && slash != pname) {
|
|
||||||
*slash = 0;
|
|
||||||
PHYSFS_mkdir(pname);
|
|
||||||
*slash = '/';
|
|
||||||
}
|
|
||||||
if (strcmp(fdir,wdir)) { /* we need COW */
|
|
||||||
//LOG_MSG("COW",pname,PHYSFS_tell(fhandle));
|
|
||||||
PHYSFS_file *whandle = PHYSFS_openWrite(pname);
|
|
||||||
if (whandle == NULL) {
|
|
||||||
LOG_MSG("PHYSFS copy-on-write failed: %s.",PHYSFS_getLastError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
char buffer[65536];
|
|
||||||
PHYSFS_sint64 size;
|
|
||||||
PHYSFS_seek(fhandle, 0);
|
|
||||||
while ((size = PHYSFS_read(fhandle,buffer,1,65536)) > 0) {
|
|
||||||
if (PHYSFS_write(whandle,buffer,1,size) != size) {
|
|
||||||
LOG_MSG("PHYSFS copy-on-write failed: %s.",PHYSFS_getLastError());
|
|
||||||
PHYSFS_close(whandle);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PHYSFS_seek(whandle, pos);
|
|
||||||
PHYSFS_close(fhandle);
|
|
||||||
fhandle = whandle;
|
|
||||||
} else { // megayuck - physfs on posix platforms uses O_APPEND. We illegally access the fd directly and clear that flag.
|
|
||||||
//LOG_MSG("noCOW",pname,PHYSFS_tell(fhandle));
|
|
||||||
PHYSFS_close(fhandle);
|
|
||||||
fhandle = PHYSFS_openAppend(pname);
|
|
||||||
#ifndef WIN32
|
|
||||||
int rc = fcntl(**(int**)fhandle->opaque,F_SETFL,0);
|
|
||||||
#endif
|
|
||||||
PHYSFS_seek(fhandle, pos);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsFile::Close() {
|
|
||||||
// only close if one reference left
|
|
||||||
if (refCtr==1) {
|
|
||||||
PHYSFS_close(fhandle);
|
|
||||||
fhandle = 0;
|
|
||||||
open = false;
|
|
||||||
};
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bit16u physfsFile::GetInformation(void) {
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
physfsFile::physfsFile(const char* _name, PHYSFS_file * handle,Bit16u devinfo, const char* physname, bool write) {
|
|
||||||
fhandle=handle;
|
|
||||||
info=devinfo;
|
|
||||||
strcpy(pname,physname);
|
|
||||||
time_t mytime = PHYSFS_getLastModTime(pname);
|
|
||||||
/* Convert the stat to a FileStat */
|
|
||||||
struct tm *time;
|
|
||||||
if((time=localtime(&mytime))!=0) {
|
|
||||||
this->time=DOS_PackTime((Bit16u)time->tm_hour,(Bit16u)time->tm_min,(Bit16u)time->tm_sec);
|
|
||||||
this->date=DOS_PackDate((Bit16u)(time->tm_year+1900),(Bit16u)(time->tm_mon+1),(Bit16u)time->tm_mday);
|
|
||||||
} else {
|
|
||||||
this->time=DOS_PackTime(0,0,0);
|
|
||||||
this->date=DOS_PackDate(1980,1,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
attr=DOS_ATTR_ARCHIVE;
|
|
||||||
last_action=(write?WRITE:READ);
|
|
||||||
|
|
||||||
open=true;
|
|
||||||
name=0;
|
|
||||||
SetName(_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfsFile::UpdateDateTimeFromHost(void) {
|
|
||||||
if(!open) return false;
|
|
||||||
time_t mytime = PHYSFS_getLastModTime(pname);
|
|
||||||
/* Convert the stat to a FileStat */
|
|
||||||
struct tm *time;
|
|
||||||
if((time=localtime(&mytime))!=0) {
|
|
||||||
this->time=DOS_PackTime((Bit16u)time->tm_hour,(Bit16u)time->tm_min,(Bit16u)time->tm_sec);
|
|
||||||
this->date=DOS_PackDate((Bit16u)(time->tm_year+1900),(Bit16u)(time->tm_mon+1),(Bit16u)time->tm_mday);
|
|
||||||
} else {
|
|
||||||
this->time=DOS_PackTime(0,0,0);
|
|
||||||
this->date=DOS_PackDate(1980,1,1);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ********************************************
|
|
||||||
// CDROM DRIVE
|
|
||||||
// ********************************************
|
|
||||||
|
|
||||||
int MSCDEX_AddDrive(char driveLetter, const char* physicalPath, Bit8u& subUnit);
|
|
||||||
bool MSCDEX_HasMediaChanged(Bit8u subUnit);
|
|
||||||
bool MSCDEX_GetVolumeName(Bit8u subUnit, char* name);
|
|
||||||
|
|
||||||
|
|
||||||
physfscdromDrive::physfscdromDrive(const char driveLetter, const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid, int& error)
|
|
||||||
:physfsDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid)
|
|
||||||
{
|
|
||||||
// Init mscdex
|
|
||||||
error = MSCDEX_AddDrive(driveLetter,startdir,subUnit);
|
|
||||||
// Get Volume Label
|
|
||||||
char name[32];
|
|
||||||
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *physfscdromDrive::GetInfo() {
|
|
||||||
char **files = PHYSFS_getSearchPath(), **list = files;
|
|
||||||
sprintf(info,"PHYSFS directory %s in ",basedir);
|
|
||||||
while (*files != NULL) {
|
|
||||||
strcat(info,*files++);
|
|
||||||
strcat(info,", ");
|
|
||||||
}
|
|
||||||
strcat(info,"CD-ROM mode (read-only)");
|
|
||||||
PHYSFS_freeList(list);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfscdromDrive::FileOpen(DOS_File * * file,const char * name,Bit32u flags)
|
|
||||||
{
|
|
||||||
if ((flags&0xf)==OPEN_READWRITE) {
|
|
||||||
flags &= ~OPEN_READWRITE;
|
|
||||||
} else if ((flags&0xf)==OPEN_WRITE) {
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return physfsDrive::FileOpen(file,name,flags);
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::FileCreate(DOS_File * * file,const char * name,Bit16u attributes)
|
|
||||||
{
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::FileUnlink(const char * name)
|
|
||||||
{
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::RemoveDir(const char * dir)
|
|
||||||
{
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::MakeDir(const char * dir)
|
|
||||||
{
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::Rename(const char * oldname,const char * newname)
|
|
||||||
{
|
|
||||||
DOS_SetError(DOSERR_ACCESS_DENIED);
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::GetFileAttr(const char * name,Bit16u * attr)
|
|
||||||
{
|
|
||||||
bool result = physfsDrive::GetFileAttr(name,attr);
|
|
||||||
if (result) *attr |= DOS_ATTR_READ_ONLY;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::FindFirst(const char * _dir,DOS_DTA & dta,bool fcb_findfirst)
|
|
||||||
{
|
|
||||||
// If media has changed, reInit drivecache.
|
|
||||||
if (MSCDEX_HasMediaChanged(subUnit)) {
|
|
||||||
dirCache.EmptyCache();
|
|
||||||
// Get Volume Label
|
|
||||||
char name[32];
|
|
||||||
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);
|
|
||||||
}
|
|
||||||
return physfsDrive::FindFirst(_dir,dta);
|
|
||||||
};
|
|
||||||
|
|
||||||
void physfscdromDrive::SetDir(const char* path)
|
|
||||||
{
|
|
||||||
// If media has changed, reInit drivecache.
|
|
||||||
if (MSCDEX_HasMediaChanged(subUnit)) {
|
|
||||||
dirCache.EmptyCache();
|
|
||||||
// Get Volume Label
|
|
||||||
char name[32];
|
|
||||||
if (MSCDEX_GetVolumeName(subUnit,name)) dirCache.SetLabel(name,true,true);
|
|
||||||
}
|
|
||||||
physfsDrive::SetDir(path);
|
|
||||||
};
|
|
||||||
|
|
||||||
bool physfscdromDrive::isRemote(void) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool physfscdromDrive::isRemovable(void) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bits physfscdromDrive::UnMount(void) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // C_HAVE_PHYSFS
|
|
@ -351,48 +351,6 @@ void MountDrive(char drive, const char drive2[DOS_PATHLENGTH]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mount_Zip(char drive, std::string temp_line) {
|
|
||||||
DOS_Drive * newdrive;
|
|
||||||
std::string str_size;
|
|
||||||
Bit16u sizes[4];
|
|
||||||
Bit8u mediaid;
|
|
||||||
mediaid=0xF8;
|
|
||||||
|
|
||||||
GetDefaultSize();
|
|
||||||
str_size=hdd_size;
|
|
||||||
|
|
||||||
char number[20];const char * scan=str_size.c_str();
|
|
||||||
Bitu index=0;Bitu count=0;
|
|
||||||
/* Parse the str_size string */
|
|
||||||
while (*scan) {
|
|
||||||
if (*scan==',') {
|
|
||||||
number[index]=0;sizes[count++]=atoi(number);
|
|
||||||
index=0;
|
|
||||||
} else number[index++]=*scan;
|
|
||||||
scan++;
|
|
||||||
}
|
|
||||||
number[index]=0;sizes[count++]=atoi(number);
|
|
||||||
|
|
||||||
temp_line.insert(0, 1, ':');
|
|
||||||
temp_line += CROSS_FILESPLIT;
|
|
||||||
if (temp_line.size() > 3 && temp_line[temp_line.size()-1]=='\\') temp_line.erase(temp_line.size()-1,1);
|
|
||||||
if (temp_line[temp_line.size()-1]!=CROSS_FILESPLIT) temp_line+=CROSS_FILESPLIT;
|
|
||||||
Bit8u bit8size=(Bit8u) sizes[1];
|
|
||||||
|
|
||||||
#if C_HAVE_PHYSFS
|
|
||||||
newdrive=new physfsDrive(temp_line.c_str(),sizes[0],bit8size,sizes[2],sizes[3],mediaid);
|
|
||||||
#else
|
|
||||||
newdrive = 0;
|
|
||||||
LOG_MSG("ERROR:This build does not support physfs");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!newdrive) E_Exit("DOS:Can't create drive");
|
|
||||||
Drives[drive-'A']=newdrive;
|
|
||||||
mem_writeb(Real2Phys(dos.tables.mediaid)+(drive-'A')*2,newdrive->GetMediaByte());
|
|
||||||
LOG_MSG("%s",newdrive->GetInfo());
|
|
||||||
LOG_MSG("Drive %c is mounted as PHYSFS directory",drive);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mount_Img_Floppy(char drive, std::string realpath) {
|
void Mount_Img_Floppy(char drive, std::string realpath) {
|
||||||
DOS_Drive * newdrive = NULL;
|
DOS_Drive * newdrive = NULL;
|
||||||
imageDisk * newImage = NULL;
|
imageDisk * newImage = NULL;
|
||||||
|
@ -2808,9 +2808,6 @@ search:
|
|||||||
Mount_Img(drive,path);
|
Mount_Img(drive,path);
|
||||||
} else if(!strcmp(ext,".ima")) {
|
} else if(!strcmp(ext,".ima")) {
|
||||||
Mount_Img_Floppy(drive,path);
|
Mount_Img_Floppy(drive,path);
|
||||||
} else if(!strcmp(ext,".zip") || (!strcmp(ext,".7z"))) {
|
|
||||||
SetCurrentDirectory( Temp_CurrentDir );
|
|
||||||
Mount_Zip(drive,path);
|
|
||||||
} else
|
} else
|
||||||
LOG_MSG("GUI: Unsupported filename extension.");
|
LOG_MSG("GUI: Unsupported filename extension.");
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ extern void* VGA_PageHandler_Func[16];
|
|||||||
|
|
||||||
Bit32u Memory_PageHandler_table[] =
|
Bit32u Memory_PageHandler_table[] =
|
||||||
{
|
{
|
||||||
NULL,
|
(Bit32u) NULL,
|
||||||
(Bit32u) &ram_page_handler,
|
(Bit32u) &ram_page_handler,
|
||||||
(Bit32u) &rom_page_handler,
|
(Bit32u) &rom_page_handler,
|
||||||
|
|
||||||
|
@ -309,7 +309,6 @@ void VGA_Init(Section* sec) {
|
|||||||
|
|
||||||
vga_force_refresh_rate = -1;
|
vga_force_refresh_rate = -1;
|
||||||
str=section->Get_string("forcerate");
|
str=section->Get_string("forcerate");
|
||||||
LOG_MSG("forcerate I got '%s'\n",str.c_str());
|
|
||||||
if (str == "ntsc")
|
if (str == "ntsc")
|
||||||
vga_force_refresh_rate = 60000.0 / 1001;
|
vga_force_refresh_rate = 60000.0 / 1001;
|
||||||
else if (str == "pal")
|
else if (str == "pal")
|
||||||
|
@ -63,7 +63,6 @@
|
|||||||
#define C_PRINTER 1
|
#define C_PRINTER 1
|
||||||
#define C_NE2000 1
|
#define C_NE2000 1
|
||||||
#define C_DIRECTLPT 1
|
#define C_DIRECTLPT 1
|
||||||
#define C_HAVE_PHYSFS 1
|
|
||||||
#define C_FLUIDSYNTH 1
|
#define C_FLUIDSYNTH 1
|
||||||
#define C_SDL_SOUND 1
|
#define C_SDL_SOUND 1
|
||||||
#define __WIN32__ 1
|
#define __WIN32__ 1
|
||||||
|
@ -422,15 +422,6 @@ public:
|
|||||||
*name++ = 0;
|
*name++ = 0;
|
||||||
if (access(buffer,F_OK)) goto nomount;
|
if (access(buffer,F_OK)) goto nomount;
|
||||||
upcase(name);
|
upcase(name);
|
||||||
if((strstr(name,".ZIP") != 0) || (strstr(name,".7Z") != 0)) {
|
|
||||||
//TODO:Add more extensions?
|
|
||||||
LOG_MSG("Mouting %s as PHYSFS write directory", buffer);
|
|
||||||
autoexec[12].Install(std::string("MOUNT C \"") + buffer + std::string(":") + name
|
|
||||||
+ std::string(":\""));
|
|
||||||
autoexec[13].Install("C:");
|
|
||||||
if(secure) autoexec[14].Install("z:\\config.com -securemode");
|
|
||||||
goto nomount;
|
|
||||||
}
|
|
||||||
autoexec[12].Install(std::string("MOUNT C \"") + buffer + "\"");
|
autoexec[12].Install(std::string("MOUNT C \"") + buffer + "\"");
|
||||||
autoexec[13].Install("C:");
|
autoexec[13].Install("C:");
|
||||||
/* Save the non-modified filename (so boot and imgmount can use it (long filenames, case sensivitive)) */
|
/* Save the non-modified filename (so boot and imgmount can use it (long filenames, case sensivitive)) */
|
||||||
|
@ -204,7 +204,7 @@ void DOS_Shell::CMD_DELETE(char * args) {
|
|||||||
ScanCMDBool(args,"AA");
|
ScanCMDBool(args,"AA");
|
||||||
|
|
||||||
StripSpaces(args);
|
StripSpaces(args);
|
||||||
if (!strcasecmp(args,"*")) args="*.*"; // 'del *' should be 'del *.*'?
|
if (!strcasecmp(args,"*")) args=(char*)("*.*"); // 'del *' should be 'del *.*'?
|
||||||
if (!strcasecmp(args,"*.*")) {
|
if (!strcasecmp(args,"*.*")) {
|
||||||
if (!optQ1) {
|
if (!optQ1) {
|
||||||
first_1:
|
first_1:
|
||||||
@ -657,7 +657,7 @@ struct copysource {
|
|||||||
|
|
||||||
void DOS_Shell::CMD_COPY(char * args) {
|
void DOS_Shell::CMD_COPY(char * args) {
|
||||||
extern Bitu ZDRIVE_NUM;
|
extern Bitu ZDRIVE_NUM;
|
||||||
char root[4] = {'A'+ZDRIVE_NUM,':','\\',0};
|
const char root[4] = {(char)('A'+ZDRIVE_NUM),':','\\',0};
|
||||||
char cmd[20];
|
char cmd[20];
|
||||||
strcpy(cmd,root);
|
strcpy(cmd,root);
|
||||||
strcat(cmd,"COPY.EXE");
|
strcat(cmd,"COPY.EXE");
|
||||||
@ -1257,7 +1257,7 @@ void DOS_Shell::CMD_DATE(char * args) {
|
|||||||
int week = ((13 * hostm - 1) / 5 + hostd + y + y/4 + century/4 - 2*century) % 7;
|
int week = ((13 * hostm - 1) / 5 + hostd + y + y/4 + century/4 - 2*century) % 7;
|
||||||
if (week < 0) week = (week + 7) % 7;
|
if (week < 0) week = (week + 7) % 7;
|
||||||
|
|
||||||
char* my_week[7]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
const char* my_week[7]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||||
WriteOut("%s %s\n",my_week[week],buffer);
|
WriteOut("%s %s\n",my_week[week],buffer);
|
||||||
} else
|
} else
|
||||||
WriteOut("%s %s\n",day, buffer);
|
WriteOut("%s %s\n",day, buffer);
|
||||||
|
@ -38,13 +38,13 @@ void DOS_Shell::ShowPrompt(void) {
|
|||||||
dir[0] = 0; //DOS_GetCurrentDir doesn't always return something. (if drive is messed up)
|
dir[0] = 0; //DOS_GetCurrentDir doesn't always return something. (if drive is messed up)
|
||||||
DOS_GetCurrentDir(0,dir);
|
DOS_GetCurrentDir(0,dir);
|
||||||
std::string line;
|
std::string line;
|
||||||
char * promptstr = "\0";
|
const char * promptstr = "\0";
|
||||||
|
|
||||||
if(GetEnvStr("PROMPT",line)) {
|
if(GetEnvStr("PROMPT",line)) {
|
||||||
std::string::size_type idx = line.find('=');
|
std::string::size_type idx = line.find('=');
|
||||||
std::string value=line.substr(idx +1 , std::string::npos);
|
std::string value=line.substr(idx +1 , std::string::npos);
|
||||||
line = std::string(promptstr) + value;
|
line = std::string(promptstr) + value;
|
||||||
promptstr=const_cast<char*>(line.c_str());
|
promptstr = line.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*promptstr) {
|
while (*promptstr) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user