Abort if we can't stat a file we're supposed to copy to userdir.
Chris Pressey
6 years ago
9 | 9 | #include <iostream> |
10 | 10 | #include <fcntl.h> |
11 | 11 | #include <cstdio> |
12 | #include <stdexcept> | |
12 | 13 | |
13 | 14 | #include "config.h" |
14 | 15 | |
96 | 97 | "charset40.bmp", |
97 | 98 | "font.bmp", |
98 | 99 | "splash.bmp", |
99 | "Printer.txt", | |
100 | 100 | "Master.dsk", |
101 | "LICENSE", | |
102 | 101 | "linapple.conf", |
103 | 102 | "icon.bmp", |
104 | 103 | "" |
123 | 122 | mkdir((userDir + CONF_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); |
124 | 123 | mkdir((userDir + SAVED_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); |
125 | 124 | mkdir((userDir + FTP_DIRECTORY_NAME).c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); |
125 | } | |
126 | 126 | |
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 | } | |
128 | 142 | |
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 | } | |
138 | 143 | return bResult; |
139 | 144 | } |
140 | 145 |