git @ Cat's Eye Technologies linapple / allow-relative-path-in-cmdline
Merge branch 'master' into allow-relative-path-in-cmdline David Baucum authored 2 years ago GitHub committed 2 years ago
8 changed file(s) with 63 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
44
55 # Where does this get installed
66 PREFIX := /usr/local
7 ASSET_DIR := $(PREFIX)/share/$(PACKAGE)
7
8 # Where assets (font file, etc) are read from
9 # (You can build a version that loads assets from the source tree with: ASSET_DIR=`pwd`/res make )
10 ASSET_DIR ?= $(PREFIX)/share/$(PACKAGE)
11
12 # Where default versions of resource files (linapple.conf, etc) are obtained from initially
13 # (You can build a version that copies resources from the source tree with: RESOURCE_INIT_DIR=`pwd`/res make )
14 RESOURCE_INIT_DIR ?= /etc/linapple
815
916 #Compiler and Linker
1017 CC := g++
4148 #DEBUGGING
4249 #CFLAGS := -Wall -O0 -ggdb -ansi -c -finstrument-functions
4350 #OPTIMIZED
44 CFLAGS := -Wall -O3 -ansi -c -DASSET_DIR=\"$(ASSET_DIR)\"
51 CFLAGS := -Wall -O3 -ansi -c -DASSET_DIR=\"$(ASSET_DIR)\" -DRESOURCE_INIT_DIR=\"$(RESOURCE_INIT_DIR)\"
4552 CFLAGS += $(SDL_CFLAGS)
4653 CFLAGS += $(CURL_CFLAGS)
4754
1111 #define LINAPPLE_VERSION 2
1212
1313 #include <curl/curl.h>
14
15 extern FILE * spMono,*spStereo;
1614
1715 extern char VERSIONSTRING[]; // Contructed in WinMain()
1816
55
66 #include <string>
77
8 #define USER_DIRECTORY_NAME "/linapple/"
8 #define USER_DIRECTORY_NAME "/.linapple/"
99 #define REGISTRY_NAME "linapple.conf"
1010 #define CONF_DIRECTORY_NAME "/conf/"
1111 #define SAVED_DIRECTORY_NAME "/saved/"
1212 #define FTP_DIRECTORY_NAME "/ftp/"
13 #define INSTALL_DIRECTORY_NAME "/etc/linapple/"
13 #ifdef RESOURCE_INIT_DIR
14 #define INSTALL_DIRECTORY_NAME RESOURCE_INIT_DIR "/"
15 #else
16 #define INSTALL_DIRECTORY_NAME "/etc/linapple/"
17 #endif
1418 #define MAX_FILENAME_LENGTH 255
1519
1620 class Config
782782 }
783783
784784
785 FILE *spMono, *spStereo;
786
787785 //---------------------------------------------------------------------------
788786
789787 int main(int argc, char * lpCmdLine[])
801799 bool bBoot = false;
802800
803801 registry = fopen(config.GetRegistryPath().c_str(), "rt"); // open conf file (linapple.conf by default)
804 spMono = fopen("speakersmono.pcm","wb");
805 spStereo = fopen("speakersstereo.pcm","wb");
806802
807803 LPSTR szImageName_drive1 = NULL; // file names for images of drive1 and drive2
808804 LPSTR szImageName_drive2 = NULL;
10951091 {
10961092 fclose(registry); //close conf file (linapple.conf by default)
10971093 }
1098 fclose(spMono);
1099 fclose(spStereo);
11001094
11011095 SDL_Quit();
11021096 // CURL routines
506506 int lf = strlen(imagefilename);
507507 if(lf > 3 && imagefilename[lf-1] == 'z' && imagefilename[lf-2] == 'g' && imagefilename[lf-3] == '.')
508508 {// .gz?
509 snprintf(tempdsk, 12, "drive%d.dsk", drive);
510 if (DiskUnGzip((char*)imagefilename, tempdsk)) {
511 writeprotected = 1;
512 createifnecessary = 0;
513 tmp = tempdsk;
514 }
509 snprintf(tempdsk, 12, "drive%d.dsk", drive);
510 if (DiskUnGzip((char*)imagefilename, tempdsk)) {
511 writeprotected = 1;
512 createifnecessary = 0;
513 tmp = tempdsk;
514 }
515515 }
516516 else
517517 if(lf > 4 && imagefilename[lf-1] == 'p' && imagefilename[lf-2] == 'i' && imagefilename[lf-3] == 'z'
518518 && imagefilename[lf-4] == '.') // .zip?
519519 {
520 snprintf(tempdsk, 12, "drive%d.dsk", drive);
521 if (DiskUnZip((char*)imagefilename, tempdsk)) {
522 writeprotected = 1;
523 createifnecessary = 0;
524 tmp = tempdsk;
525 }
520 snprintf(tempdsk, 12, "drive%d.dsk", drive);
521 if (DiskUnZip((char*)imagefilename, tempdsk)) {
522 writeprotected = 1;
523 createifnecessary = 0;
524 tmp = tempdsk;
525 }
526526 }
527527
528528 fptr->writeprotected = writeprotected;
537537 snprintf(s_title, MAX_DISK_IMAGE_NAME + 32, "%s - %s", g_pAppTitle, tmp); //
538538 if(drive == 0) SDL_WM_SetCaption(s_title, g_pAppTitle);// change caption just for drive 0 (leading)
539539 printf("Disk is inserted. Full name = %s\n", /*g_aFloppyDisk[drive].fullname*/imagefilename);
540 }
541 else
542 {
543 printf("Error %d when inserting disk %s\n", error, imagefilename);
540544 }
541545 return error;
542546 }
857857 #ifdef RAMWORKS
858858 if ( ((SW_PAGE2 && SW_80STORE) || VideoGetSW80COL()) &&
859859 ( ( ((offset & 0xFF00)>=0x0400) &&
860 ((offset & 0xFF00)<=0700) ) ||
860 ((offset & 0xFF00)<=0x700) ) ||
861861 ( SW_HIRES && ((offset & 0xFF00)>=0x2000) &&
862862 ((offset & 0xFF00)<=0x3F00) ) ) ) {
863863 lpMem = (memshadow[(offset >> 8)] == (RWpages[0]+(offset & 0xFF00)))
4444 SDL_Surface *surf;
4545 char *path = (char *)SDL_malloc(sizeof(char[PATH_MAX]));
4646 if (NULL == path) {
47 fprintf(stderr, "Asset_Init: Allocating path: %s\n", SDL_GetError());
47 fprintf(stderr, "Asset_LoadBMP: Allocating path: %s\n", SDL_GetError());
4848 return NULL;
4949 }
5050
5353 if (NULL == surf) {
5454 snprintf(path, PATH_MAX, "%s%s", system_exedir, filename);
5555 surf = SDL_LoadBMP(path);
56 if (NULL == surf) {
57 fprintf(stderr, "Asset_LoadBMP: Couldn't load %s in either %s or %s!\n",
58 filename, system_assets, system_exedir);
59 }
56 }
57
58 if (NULL != surf) {
59 fprintf(stderr, "Asset_LoadBMP: Loaded %s from %s\n", filename, path);
60 } else {
61 fprintf(stderr, "Asset_LoadBMP: Couldn't load %s in either %s or %s!\n",
62 filename, system_assets, system_exedir);
6063 }
6164
6265 SDL_free(path);
99 #include <iostream>
1010 #include <fcntl.h>
1111 #include <cstdio>
12 #include <stdexcept>
1213
1314 #include "config.h"
1415
3334 // Simple POSIX file copy
3435 bool Config::CopyFile(std::string srcFile, std::string destFile)
3536 {
36 const int bufSize = 1024;
37 const int bufSize = 1024;
3738 bool bRet = true;
3839 char buf[bufSize];
3940 size_t size;
41
42 std::cout << "Copying '" << srcFile.c_str() << "' to '" << destFile.c_str() << "'" << std::endl;
4043
4144 // Attempt to open files
4245 int source = open(srcFile.c_str(), O_RDONLY, 0);
4851 while ((size = read(source, buf, bufSize)) > 0) {
4952 if(0 >= write(dest, buf, size)) {
5053 // Handle error;
51 std::cout << "Error writing '" << destFile.c_str() << "' (" << size << ")" << std::endl;
52 std::cout << "Source file: " << srcFile.c_str() << std::endl;
53
54 std::cout << "Error writing '" << destFile.c_str() << "' (" << size << ")" << std::endl;
55 std::cout << "Source file: " << srcFile.c_str() << std::endl;
5456 bRet = false;
5557 break;
5658 }
6466 close(dest);
6567 }
6668 } else {
67 std::cout << "Error copying '" << srcFile.c_str() << "' to '" << destFile.c_str() << "'" << std::endl;
69 std::cout << "Error copying '" << srcFile.c_str() << "' to '" << destFile.c_str() << "'" << std::endl;
6870 bRet = false;
6971 }
7072 return bRet;
8486 "charset40.bmp",
8587 "font.bmp",
8688 "splash.bmp",
87 "Printer.txt",
8889 "Master.dsk",
89 "LICENSE",
9090 "linapple.conf",
9191 "icon.bmp",
9292 ""
111111 mkdir((userDir + CONF_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
112112 mkdir((userDir + SAVED_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
113113 mkdir((userDir + FTP_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
114 }
114115
115 cout << "Copying Files\n" << std::endl;
116 cout << "Copying Files" << std::endl;
117 for( unsigned int i = 0; *files[ i ]; i++ ) {
118 string src = (GetInstallPath() + files[ i ]);
119 string dest = (GetUserFilePath() + files[ i ]);
120 if (stat (dest.c_str(), &buffer) == 0) {
121 // It's already there.
122 continue;
123 }
124 if (!(stat (src.c_str(), &buffer) == 0)) {
125 cout << "Could not stat " << src << "." << std::endl;
126 cout << "Please ensure " << GetInstallPath() << " exists and contains the linapple resource files." << std::endl;
127 throw std::runtime_error("could not copy resource files");
128 }
129 CopyFile(src, dest);
130 }
116131
117 // Copy config options file
118 for( unsigned int i = 0; *files[ i ]; i++ ) {
119 string dest = GetUserFilePath();
120 CopyFile(
121 (GetInstallPath() + files[ i ]),
122 dest + files[ i ]
123 );
124 }
125 }
126132 return bResult;
127133 }
128134