Windows vm now tries vm-console.image or vm.image first, then removes -console if it exists and tries to find the image again

db4
Doug Coleman 2009-01-29 19:57:01 -06:00
parent 5e4265507e
commit ed7b49df78
5 changed files with 64 additions and 51 deletions

View File

@ -3,7 +3,7 @@ AR = ar
LD = ld
EXECUTABLE = factor
CONSOLE_EXECUTABLE = factor_console
CONSOLE_EXECUTABLE = factor-console
VERSION = 0.92
IMAGE = factor.image
@ -140,15 +140,10 @@ zlib1.dll:
winnt-x86-32: freetype6.dll zlib1.dll
$(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32
$(MAKE) $(CONSOLE_EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.32
$(MAKE) winnt-finish
winnt-x86-64:
$(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.64
$(MAKE) $(CONSOLE_EXECUTABLE) CONFIG=vm/Config.windows.nt.x86.64
$(MAKE) winnt-finish
winnt-finish:
cp misc/factor-cygwin.sh ./factor
wince-arm:
$(MAKE) $(EXECUTABLE) CONFIG=vm/Config.windows.ce.arm
@ -169,10 +164,10 @@ factor: $(DLL_OBJS) $(EXE_OBJS)
$(CC) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
$(CFLAGS) -o $@$(EXE_SUFFIX)$(EXE_EXTENSION) $(EXE_OBJS)
factor_console: $(DLL_OBJS) $(EXE_OBJS)
factor-console: $(DLL_OBJS) $(EXE_OBJS)
$(LINKER) $(ENGINE) $(DLL_OBJS)
$(CC) $(LIBS) $(LIBPATH) -L. $(LINK_WITH_ENGINE) \
$(CFLAGS) $(CFLAGS_CONSOLE) -o $(EXECUTABLE)$(EXE_SUFFIX)$(CONSOLE_EXE_EXTENSION) $(EXE_OBJS)
$(CFLAGS) $(CFLAGS_CONSOLE) -o $@$(EXE_SUFFIX)$(EXE_EXTENSION) $(EXE_OBJS)
clean:
rm -f vm/*.o

View File

@ -1,2 +0,0 @@
#! /bin/sh
./factor.com "$@"

View File

@ -2,7 +2,6 @@ CFLAGS += -DWINDOWS -mno-cygwin
LIBS = -lm
PLAF_DLL_OBJS += vm/os-windows.o
EXE_EXTENSION=.exe
CONSOLE_EXE_EXTENSION=.com
DLL_EXTENSION=.dll
LINKER = $(CC) -shared -mno-cygwin -o
LINK_WITH_ENGINE = -l$(DLL_PREFIX)factor$(DLL_SUFFIX)

View File

@ -59,39 +59,9 @@ void ffi_dlclose(F_DLL *dll)
dll->dll = NULL;
}
/* You must free() this yourself. */
const F_CHAR *default_image_path(void)
{
F_CHAR full_path[MAX_UNICODE_PATH];
F_CHAR *ptr;
F_CHAR path_temp[MAX_UNICODE_PATH];
if(!GetModuleFileName(NULL, full_path, MAX_UNICODE_PATH))
fatal_error("GetModuleFileName() failed", 0);
if((ptr = wcsrchr(full_path, '.')))
*ptr = 0;
snwprintf(path_temp, sizeof(path_temp)-1, L"%s.image", full_path);
path_temp[sizeof(path_temp) - 1] = 0;
return safe_strdup(path_temp);
}
/* You must free() this yourself. */
const F_CHAR *vm_executable_path(void)
{
F_CHAR full_path[MAX_UNICODE_PATH];
if(!GetModuleFileName(NULL, full_path, MAX_UNICODE_PATH))
fatal_error("GetModuleFileName() failed", 0);
return safe_strdup(full_path);
}
void primitive_existsp(void)
bool windows_stat(F_CHAR *path)
{
BY_HANDLE_FILE_INFORMATION bhfi;
F_CHAR *path = unbox_u16_string();
HANDLE h = CreateFileW(path,
GENERIC_READ,
FILE_SHARE_READ,
@ -107,17 +77,67 @@ void primitive_existsp(void)
HANDLE h;
if(INVALID_HANDLE_VALUE == (h = FindFirstFile(path, &st)))
dpush(F);
else
{
FindClose(h);
dpush(T);
}
return;
return false;
FindClose(h);
return true;
}
bool ret;
ret = GetFileInformationByHandle(h, &bhfi);
CloseHandle(h);
return ret;
}
void windows_image_path(F_CHAR *full_path, F_CHAR *temp_path, unsigned int length)
{
snwprintf(temp_path, length-1, L"%s.image", full_path);
temp_path[sizeof(temp_path) - 1] = 0;
}
/* You must free() this yourself. */
const F_CHAR *default_image_path(void)
{
F_CHAR full_path[MAX_UNICODE_PATH];
F_CHAR *ptr;
F_CHAR temp_path[MAX_UNICODE_PATH];
if(!GetModuleFileName(NULL, full_path, MAX_UNICODE_PATH))
fatal_error("GetModuleFileName() failed", 0);
if((ptr = wcsrchr(full_path, '.')))
*ptr = 0;
snwprintf(temp_path, sizeof(temp_path)-1, L"%s.image", full_path);
temp_path[sizeof(temp_path) - 1] = 0;
if(!windows_stat(temp_path)) {
unsigned int len = wcslen(full_path);
F_CHAR magic[] = L"-console";
unsigned int magic_len = wcslen(magic);
if(!wcsncmp(full_path + len - magic_len, magic, MIN(len, magic_len)))
full_path[len - magic_len] = 0;
snwprintf(temp_path, sizeof(temp_path)-1, L"%s.image", full_path);
temp_path[sizeof(temp_path) - 1] = 0;
}
box_boolean(GetFileInformationByHandle(h, &bhfi));
CloseHandle(h);
return safe_strdup(temp_path);
}
/* You must free() this yourself. */
const F_CHAR *vm_executable_path(void)
{
F_CHAR full_path[MAX_UNICODE_PATH];
if(!GetModuleFileName(NULL, full_path, MAX_UNICODE_PATH))
fatal_error("GetModuleFileName() failed", 0);
return safe_strdup(full_path);
}
void primitive_existsp(void)
{
F_CHAR *path = unbox_u16_string();
box_boolean(windows_stat(path));
}
F_SEGMENT *alloc_segment(CELL size)

View File

@ -19,6 +19,7 @@ typedef wchar_t F_CHAR;
#define STRCMP wcscmp
#define STRNCMP wcsncmp
#define STRDUP _wcsdup
#define MIN(a,b) ((a)>(b)?(b):(a))
#ifdef WIN64
#define CELL_FORMAT "%Iu"