comparison system/file.cc @ 43:01aa5ddf7dc8

A lot of very minor improvements (deleted some unused variables, and other things like that...)
author thib
date Tue, 24 Mar 2009 19:45:48 +0000
parents 2c574c3d50a9
children 5f548e5957a8
comparison
equal deleted inserted replaced
42:039d813d4cef 43:01aa5ddf7dc8
135 } 135 }
136 return; 136 return;
137 } 137 }
138 138
139 void ARCFILE::Init(void) { 139 void ARCFILE::Init(void) {
140 int i;
141 if (! arc_atom.empty()) return; 140 if (! arc_atom.empty()) return;
142 if (arcname == 0) return; 141 if (arcname == 0) return;
143 /* ファイル数を得る */ 142 /* ファイル数を得る */
144 int slen = CheckFileDeal(); 143 int slen = CheckFileDeal();
145 /* ファイル名のセット */ 144 /* ファイル名のセット */
263 delete[] new_path; 262 delete[] new_path;
264 return 0; 263 return 0;
265 } 264 }
266 265
267 void ARCFILE::ListFiles(FILE* out) { 266 void ARCFILE::ListFiles(FILE* out) {
268 int i;
269 Init(); 267 Init();
270 if (arc_atom.empty()) return; 268 if (arc_atom.empty()) return;
271 // list file name... 269 // list file name...
272 fprintf(out,"%16s %10s %10s %10s\n", "Filename", 270 fprintf(out,"%16s %10s %10s %10s\n", "Filename",
273 "pointer","arcsize", "filesize"); 271 "pointer","arcsize", "filesize");
375 } 373 }
376 closedir(dir); 374 closedir(dir);
377 return flen; 375 return flen;
378 } 376 }
379 void DIRFILE::ListupFiles(int fname_len) { 377 void DIRFILE::ListupFiles(int fname_len) {
380 DIR* dir; int i; 378 DIR* dir;
381 fname_len *= 2; 379 fname_len *= 2;
382 dir = opendir(arcname); 380 dir = opendir(arcname);
383 if (dir == 0) { 381 if (dir == 0) {
384 fprintf(stderr, "Cannot open dir file : %s\n",arcname); 382 fprintf(stderr, "Cannot open dir file : %s\n",arcname);
385 return; 383 return;
752 } 750 }
753 return searcher[type]->Find(fname,ext); 751 return searcher[type]->Find(fname,ext);
754 } 752 }
755 753
756 char** FILESEARCH::ListAll(FILETYPE type) { 754 char** FILESEARCH::ListAll(FILETYPE type) {
757 int i;
758 /* とりあえず searcher を初期化 */ 755 /* とりあえず searcher を初期化 */
759 Find(type, "THIS FILENAME MAY NOT EXIST IN THE FILE SYSTEM !!!"); 756 Find(type, "THIS FILENAME MAY NOT EXIST IN THE FILE SYSTEM !!!");
760 if (searcher[type] == 0) return 0; 757 if (searcher[type] == 0) return 0;
761 /* 全ファイルのリストアップ */ 758 /* 全ファイルのリストアップ */
762 int deal = 0; 759 int deal = 0;
993 990
994 GRPCONV* GRPCONV::AssignConverter(const char* inbuf, int inlen, const char* fname) { 991 GRPCONV* GRPCONV::AssignConverter(const char* inbuf, int inlen, const char* fname) {
995 /* ファイルの内容に応じたコンバーターを割り当てる */ 992 /* ファイルの内容に応じたコンバーターを割り当てる */
996 GRPCONV* conv = 0; 993 GRPCONV* conv = 0;
997 if (inlen < 10) return 0; /* invalid file */ 994 if (inlen < 10) return 0; /* invalid file */
998 if (conv == 0 && strncmp(inbuf, "PDT10", 5) == 0 || strncmp(inbuf, "PDT11", 5) == 0) { /* PDT10 or PDT11 */ 995 if (strncmp(inbuf, "PDT10", 5) == 0 || strncmp(inbuf, "PDT11", 5) == 0) { /* PDT10 or PDT11 */
999 conv = new PDTCONV(inbuf, inlen, fname); 996 conv = new PDTCONV(inbuf, inlen, fname);
1000 if (conv->data == 0) { delete conv; conv = 0;} 997 if (conv->data == 0) { delete conv; conv = 0;}
1001 } 998 }
1002 #if HAVE_LIBPNG 999 #if HAVE_LIBPNG
1003 unsigned char png_magic[4] = {0x89, 'P', 'N', 'G'}; 1000 unsigned char png_magic[4] = {0x89, 'P', 'N', 'G'};
1491 // まず展開 1488 // まず展開
1492 const char* src = data + 13; 1489 const char* src = data + 13;
1493 const char* srcend = data + datalen; 1490 const char* srcend = data + datalen;
1494 char* dest = uncompress_data; 1491 char* dest = uncompress_data;
1495 char* dstend = uncompress_data + uncompress_size; 1492 char* dstend = uncompress_data + uncompress_size;
1496 while(lzExtract(Extract_DataType_G00Type0(), char(), src, dest, srcend, dstend)); 1493 while(lzExtract(Extract_DataType_G00Type0(), char(), src, dest, srcend, dstend)){};
1497 // image にコピー 1494 // image にコピー
1498 CopyRGB(image, uncompress_data); 1495 CopyRGB(image, uncompress_data);
1499 delete[] uncompress_data; 1496 delete[] uncompress_data;
1500 return true; 1497 return true;
1501 } 1498 }
1508 const char* src = data + 13; 1505 const char* src = data + 13;
1509 const char* srcend = data + datalen; 1506 const char* srcend = data + datalen;
1510 char* dest = uncompress_data; 1507 char* dest = uncompress_data;
1511 char* destend = uncompress_data + uncompress_size; 1508 char* destend = uncompress_data + uncompress_size;
1512 1509
1513 while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend)); 1510 while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend)){};
1514 1511
1515 int colortable[256]; 1512 int colortable[256];
1516 memset(colortable, 0, sizeof(int)*256); 1513 memset(colortable, 0, sizeof(int)*256);
1517 int colortable_len = read_little_endian_short(uncompress_data); 1514 int colortable_len = read_little_endian_short(uncompress_data);
1518 if (colortable_len > 256) colortable_len = 256; 1515 if (colortable_len > 256) colortable_len = 256;
1553 1550
1554 const char* src = head + 8; 1551 const char* src = head + 8;
1555 const char* srcend = data + datalen; 1552 const char* srcend = data + datalen;
1556 char* dest = uncompress_data; 1553 char* dest = uncompress_data;
1557 char* destend = uncompress_data + uncompress_size; 1554 char* destend = uncompress_data + uncompress_size;
1558 while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend)); 1555 while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend)){};
1559 1556
1560 /* region_deal2 == region_deal のはず……*/ 1557 /* region_deal2 == region_deal のはず……*/
1561 int region_deal2 = read_little_endian_int(uncompress_data); 1558 int region_deal2 = read_little_endian_int(uncompress_data);
1562 if (region_deal > region_deal2) region_deal = region_deal2; 1559 if (region_deal > region_deal2) region_deal = region_deal2;
1563 1560
1755 } 1752 }
1756 #endif /* HAVE_LIBPNG */ 1753 #endif /* HAVE_LIBPNG */
1757 1754
1758 #if HAVE_LIBJPEG 1755 #if HAVE_LIBJPEG
1759 JPEGCONV::JPEGCONV(const char* _inbuf, int _inlen, const char* _filename) { 1756 JPEGCONV::JPEGCONV(const char* _inbuf, int _inlen, const char* _filename) {
1760 int w,h,type;
1761 JSAMPARRAY rows, rows_orig; int i;
1762 char* buf = 0;
1763
1764 struct jpeg_decompress_struct cinfo; 1757 struct jpeg_decompress_struct cinfo;
1765 struct jpeg_error_mgr jerr; 1758 struct jpeg_error_mgr jerr;
1766 cinfo.err = jpeg_std_error(&jerr); 1759 cinfo.err = jpeg_std_error(&jerr);
1767 jpeg_create_decompress(&cinfo); 1760 jpeg_create_decompress(&cinfo);
1768 cinfo.src = new jpeg_source_mgr; 1761 cinfo.src = new jpeg_source_mgr;