• R/O
  • SSH
  • HTTPS

jyeipegyuu: Commit


Commit MetaInfo

Révision6 (tree)
l'heure2009-04-06 02:18:52
Auteurberupon

Message de Log

sconsの設定ファイル追加。なんだか環境変数を設定しないといけないのがアレだけど、そこだけ環境毎に切り換えれば済むのでまだ幸せなんだろか。。

Change Summary

Modification

--- stdafx.h (revision 5)
+++ stdafx.h (revision 6)
@@ -8,11 +8,11 @@
88 #include "targetver.h"
99
1010 #include <stdio.h>
11-#include <tchar.h>
11+//#include <tchar.h>
1212
1313
1414 template <typename T>
15-__forceinline void OffsetPtr(T*& ptr, int offsetBytes)
15+inline void OffsetPtr(T*& ptr, int offsetBytes)
1616 {
1717 ptr = (T*) ((const char*)ptr + offsetBytes);
1818 }
--- misc.h (revision 5)
+++ misc.h (revision 6)
@@ -1,3 +1,5 @@
1+
2+#include <string.h>
13
24 template <typename T>
35 void gather(
@@ -140,7 +142,7 @@
140142 };
141143
142144 enum RiceCoderFlag {
143- None = 0xFF,
145+ RiceCoderFlag_None = 0xFF,
144146 };
145147
146148 size_t compressSub(
@@ -221,7 +223,7 @@
221223 size_t len = 0;
222224 if (initialCompressedLen < compressedLen && initialCompressedLen < bytesLen) {
223225 *dest++ = 1;
224- *dest++ = RiceCoderFlag::None;
226+ *dest++ = RiceCoderFlag_None;
225227 len = initialCompressedLen;
226228 memcpy(dest+4, tmp, len);
227229 }else if (compressedLen < bytesLen) {
@@ -480,7 +482,7 @@
480482 len2 = len;
481483 }
482484
483- if (b == RiceCoderFlag::None) {
485+ if (b == RiceCoderFlag_None) {
484486 memcpy(dest, tmp, len2);
485487 for (size_t i=0; i<len2/4; ++i) {
486488 int val = dest[i];
--- BZip2Compressor.cpp (revision 5)
+++ BZip2Compressor.cpp (revision 6)
@@ -1,8 +1,8 @@
1-#include "stdafx.h"
1+//#include "stdafx.h"
22
33 #include "BZip2Compressor.h"
44
5-#include "bzlib.h"
5+#include <bzlib.h>
66 #pragma comment(lib, "libbz2.lib")
77
88 size_t BZip2Compressor::Compress(
@@ -13,7 +13,7 @@
1313 )
1414 {
1515 size_t compressedLen = destLen;
16- BZ2_bzBuffToBuffCompress((char*)dest, &compressedLen, (char*)src, srcLen, 9, 0, 30);
16+ BZ2_bzBuffToBuffCompress((char*)dest, (unsigned int*)&compressedLen, (char*)src, (unsigned int)srcLen, 9, 0, 30);
1717 return compressedLen;
1818 }
1919
@@ -25,7 +25,7 @@
2525 )
2626 {
2727 size_t decompressedLen = destLen;
28- BZ2_bzBuffToBuffDecompress((char*)dest, &decompressedLen, (char*)src, srcLen, 0, 0);
28+ BZ2_bzBuffToBuffDecompress((char*)dest, (unsigned int*)&decompressedLen, (char*)src, (unsigned int)srcLen, 0, 0);
2929 return decompressedLen;
3030 }
3131
--- ICompressor.h (revision 5)
+++ ICompressor.h (revision 6)
@@ -1,4 +1,6 @@
11 #pragma once
2+
3+#include <stdlib.h>
24
35 class ICompressor
46 {
--- main.cpp (revision 5)
+++ main.cpp (revision 6)
@@ -18,16 +18,16 @@
1818 #include "ReadImage/ReadImage.h"
1919 #include "ReadImage/File.h"
2020
21-int _tmain(int argc, _TCHAR* argv[])
21+int main(int argc, char* argv[])
2222 {
2323 if (argc < 2) {
24- _tprintf(_T("specify filename\n"));
24+ printf("specify filename\n");
2525 return 1;
2626 }
2727
28- FILE* f = _tfopen(argv[1], _T("rb"));
28+ FILE* f = fopen(argv[1], "rb");
2929 if (!f) {
30- _tprintf(_T("failed to open file : %s\n"), argv[1]);
30+ printf("failed to open file : %s\n", argv[1]);
3131 return 1;
3232 }
3333 File fo(f);
@@ -82,6 +82,6 @@
8282 //fwrite(pOutput, 1, size, of);
8383 //fclose(of);
8484
85- _tprintf(_T("%f%% %d bytes"), (100.0 * compressedLen) / size, compressedLen);
85+ printf("%f%% %zu bytes", (100.0 * compressedLen) / size, compressedLen);
8686 return 0;
8787 }
--- ReadImage/ReadImage.cpp (revision 5)
+++ ReadImage/ReadImage.cpp (revision 6)
@@ -4,8 +4,38 @@
44
55 #define TRACE printf
66 #include <assert.h>
7+#include <stdio.h>
78
8-#include <windows.h>
9+//#include <windows.h>
10+
11+#define BI_BITFIELDS 3
12+
13+typedef unsigned short WORD;
14+typedef unsigned int DWORD;
15+typedef long LONG;
16+
17+typedef struct tagBITMAPINFOHEADER {
18+ DWORD biSize;
19+ LONG biWidth;
20+ LONG biHeight;
21+ WORD biPlanes;
22+ WORD biBitCount;
23+ DWORD biCompression;
24+ DWORD biSizeImage;
25+ LONG biXPelsPerMeter;
26+ LONG biYPelsPerMeter;
27+ DWORD biClrUsed;
28+ DWORD biClrImportant;
29+} BITMAPINFOHEADER;
30+
31+typedef struct tagBITMAPFILEHEADER {
32+ WORD bfType;
33+ DWORD bfSize; /* DWORD (4バイト) 境界にアラインされていない点に注意.*/
34+ WORD bfReserved1;
35+ WORD bfReserved2;
36+ DWORD bfOffBits; /* DWORD (4バイト) 境界にアラインされていない点に注意.*/
37+} BITMAPFILEHEADER;
38+
939
1040 bool Read_BITMAPINFOHEADER(IFile& file, BITMAPINFOHEADER& bmih)
1141 {
@@ -47,7 +77,7 @@
4777
4878 bool ReadImageData_BMP(IFile& file, unsigned char* dest, int lineOffset, void* palettes)
4979 {
50- file.Seek(0, FILE_BEGIN);
80+ file.Seek(0, SEEK_SET);
5181 BITMAPINFOHEADER bmih;
5282 if (!Read_BITMAPINFOHEADER(file, bmih)) {
5383 return false;
--- ReadImage/File.cpp (revision 5)
+++ ReadImage/File.cpp (revision 6)
@@ -1,60 +1,52 @@
11 #include "stdafx.h"
22 #include "File.h"
33
4-#include <io.h>
4+//#include <io.h>
55 #include <assert.h>
66 #include <memory.h>
77 #include <stdio.h>
88
9-#include <windows.h>
10-
11-File::File(HANDLE hFile)
12- :
13- hFile_(hFile)
9+File::File(FILE* file)
1410 {
11+ file_ = file;
1512 }
1613
17-File::File(FILE* pFile)
18-{
19- hFile_ = (HANDLE) _get_osfhandle(_fileno(pFile));
20-}
21-
2214 bool File::Read(void* pBuffer, size_t nNumberOfBytesToRead, size_t& nNumberOfBytesRead)
23-{
24- return ReadFile(hFile_, pBuffer, nNumberOfBytesToRead, (LPDWORD)&nNumberOfBytesRead, NULL);
15+{
16+ nNumberOfBytesRead = fread(pBuffer, 1, nNumberOfBytesToRead, file_);
17+ return nNumberOfBytesRead;
2518 }
2619
2720 bool File::Write(const void* pBuffer, size_t nNumberOfBytesToWrite, size_t& nNumberOfBytesWritten)
28-{
29- return WriteFile(hFile_, pBuffer, nNumberOfBytesToWrite, (LPDWORD)&nNumberOfBytesWritten, NULL);
21+{
22+ nNumberOfBytesWritten = fwrite(pBuffer, 1, nNumberOfBytesToWrite, file_);
23+ return nNumberOfBytesWritten;
3024 }
3125
3226 size_t File::Seek(long lDistanceToMove, size_t dwMoveMethod)
33-{
34- return SetFilePointer(hFile_, lDistanceToMove, NULL, dwMoveMethod);
27+{
28+ return fseek(file_, lDistanceToMove, dwMoveMethod);
3529 }
3630
3731 size_t File::Tell() const
38-{
39- /*
40- -- Reference --
41- http://nukz.net/reference/fileio/hh/winbase/filesio_3vhu.htm
42- */
43- return SetFilePointer(
44- hFile_, // must have GENERIC_READ and/or GENERIC_WRITE
45- 0, // do not move pointer
46- NULL, // hFile is not large enough to need this pointer
47- FILE_CURRENT
48- ); // provides offset from current position
32+{
33+ return ftell(file_);
4934 }
5035
5136 size_t File::Size() const
52-{
53- return GetFileSize(hFile_, NULL);
37+{
38+ fpos_t pos;
39+ fgetpos( file_, &pos );
40+ fseek( file_, 0, SEEK_END );
41+ long pos2 = ftell(file_);
42+// fgetpos( file_, &pos2 );
43+ fsetpos( file_, &pos );
44+ return pos2;
45+// return GetFileSize(hFile_, NULL);
5446 }
5547
5648 bool File::Flush()
5749 {
58- return FlushFileBuffers(hFile_);
50+ fflush(file_);
5951 }
6052
--- ReadImage/File.h (revision 5)
+++ ReadImage/File.h (revision 6)
@@ -2,16 +2,13 @@
22
33 #include "IFile.h"
44
5-#include <windows.h>
65 #include <stdio.h>
76
87 class File : public IFile
98 {
109 public:
11- File(HANDLE hFile);
10+ File(FILE* file);
1211
13- File(FILE* pFile);
14-
1512 bool Read(void* pBuffer, size_t nNumberOfBytesToRead, size_t& nNumberOfBytesRead);
1613
1714 bool Write(const void* pBuffer, size_t nNumberOfBytesToWrite, size_t& nNumberOfBytesWritten);
@@ -28,6 +25,6 @@
2825 virtual const void* GetBuffer() const { return 0; }
2926
3027 private:
31- HANDLE hFile_;
28+ FILE* file_;
3229 };
3330
--- ReadImage/IFile.h (revision 5)
+++ ReadImage/IFile.h (revision 6)
@@ -15,6 +15,8 @@
1515 InterfaceをWindowsAPIのFile関数に似せています
1616
1717 */
18+
19+#include <stdlib.h>
1820
1921 class IFile
2022 {
Afficher sur ancien navigateur de dépôt.