git @ Cat's Eye Technologies linapple / stylistic-cleanup
Stylistic cleanups that were in my `userdir-vs-assets` branch. Chris Pressey 2 years ago
3 changed file(s) with 29 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
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 }
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);
4545 // Simple POSIX file copy
4646 bool Config::CopyFile(std::string srcFile, std::string destFile)
4747 {
48 const int bufSize = 1024;
48 const int bufSize = 1024;
4949 bool bRet = true;
5050 char buf[bufSize];
5151 size_t size;
52
53 std::cout << "Copying '" << srcFile.c_str() << "' to '" << destFile.c_str() << "'" << std::endl;
5254
5355 // Attempt to open files
5456 int source = open(srcFile.c_str(), O_RDONLY, 0);
6062 while ((size = read(source, buf, bufSize)) > 0) {
6163 if(0 >= write(dest, buf, size)) {
6264 // Handle error;
63 std::cout << "Error writing '" << destFile.c_str() << "' (" << size << ")" << std::endl;
64 std::cout << "Source file: " << srcFile.c_str() << std::endl;
65
65 std::cout << "Error writing '" << destFile.c_str() << "' (" << size << ")" << std::endl;
66 std::cout << "Source file: " << srcFile.c_str() << std::endl;
6667 bRet = false;
6768 break;
6869 }
7677 close(dest);
7778 }
7879 } else {
79 std::cout << "Error copying '" << srcFile.c_str() << "' to '" << destFile.c_str() << "'" << std::endl;
80 std::cout << "Error copying '" << srcFile.c_str() << "' to '" << destFile.c_str() << "'" << std::endl;
8081 bRet = false;
8182 }
8283 return bRet;