git @ Cat's Eye Technologies linapple / abort-on-resource-not-found
Abort if we can't stat a file we're supposed to copy to userdir. Chris Pressey 2 years ago
1 changed file(s) with 17 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
99 #include <iostream>
1010 #include <fcntl.h>
1111 #include <cstdio>
12 #include <stdexcept>
1213
1314 #include "config.h"
1415
9697 "charset40.bmp",
9798 "font.bmp",
9899 "splash.bmp",
99 "Printer.txt",
100100 "Master.dsk",
101 "LICENSE",
102101 "linapple.conf",
103102 "icon.bmp",
104103 ""
123122 mkdir((userDir + CONF_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
124123 mkdir((userDir + SAVED_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
125124 mkdir((userDir + FTP_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
125 }
126126
127 cout << "Copying Files\n" << std::endl;
127 cout << "Copying Files" << std::endl;
128 for( unsigned int i = 0; *files[ i ]; i++ ) {
129 string src = (GetInstallPath() + files[ i ]);
130 string dest = (GetUserFilePath() + files[ i ]);
131 if (stat (dest.c_str(), &buffer) == 0) {
132 // It's already there.
133 continue;
134 }
135 if (!(stat (src.c_str(), &buffer) == 0)) {
136 cout << "Could not stat " << src << "." << std::endl;
137 cout << "Please ensure " << GetInstallPath() << " exists and contains the linapple resource files." << std::endl;
138 throw std::runtime_error("could not copy resource files");
139 }
140 CopyFile(src, dest);
141 }
128142
129 // Copy config options file
130 for( unsigned int i = 0; *files[ i ]; i++ ) {
131 string dest = GetUserFilePath();
132 CopyFile(
133 (GetInstallPath() + files[ i ]),
134 dest + files[ i ]
135 );
136 }
137 }
138143 return bResult;
139144 }
140145