Set native eol-style on some recently added files.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6716 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2011-01-01 21:09:56 +00:00
parent 6ffdbe8482
commit 8fca9a8e8d
2 changed files with 172 additions and 172 deletions

View File

@ -1,106 +1,106 @@
// Copyright (C) 2003 Dolphin Project. // Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0. // the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details. // GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program. // A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/ // If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifdef _WIN32 #ifdef _WIN32
#include "stdafx.h" #include "stdafx.h"
#endif #endif
#include "Blob.h" #include "Blob.h"
#include "CISOBlob.h" #include "CISOBlob.h"
namespace DiscIO namespace DiscIO
{ {
CISOFileReader::CISOFileReader(FILE* file__) CISOFileReader::CISOFileReader(FILE* file__)
{ {
file_ = file__; file_ = file__;
fseek(file_, 0, SEEK_END); fseek(file_, 0, SEEK_END);
size = ftell(file_); size = ftell(file_);
fseek(file_, 0, SEEK_SET); fseek(file_, 0, SEEK_SET);
memset(&header, 0, sizeof(header)); memset(&header, 0, sizeof(header));
fread(&header, sizeof(header), 1, file_); fread(&header, sizeof(header), 1, file_);
CISO_Map_t count = 0; CISO_Map_t count = 0;
int idx; int idx;
for (idx = 0; idx < CISO_MAP_SIZE; idx++) for (idx = 0; idx < CISO_MAP_SIZE; idx++)
ciso_map[idx] = (header.map[idx] == 1) ? count++ : CISO_UNUSED_BLOCK; ciso_map[idx] = (header.map[idx] == 1) ? count++ : CISO_UNUSED_BLOCK;
} }
CISOFileReader* CISOFileReader::Create(const char* filename) CISOFileReader* CISOFileReader::Create(const char* filename)
{ {
if (IsCISOBlob(filename)) if (IsCISOBlob(filename))
{ {
FILE* file_ = fopen(filename, "rb"); FILE* file_ = fopen(filename, "rb");
return new CISOFileReader(file_); return new CISOFileReader(file_);
} }
else else
return NULL; return NULL;
} }
CISOFileReader::~CISOFileReader() CISOFileReader::~CISOFileReader()
{ {
fclose(file_); fclose(file_);
} }
bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) bool CISOFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
{ {
u64 bytesRead = 0; u64 bytesRead = 0;
while (bytesRead < nbytes) while (bytesRead < nbytes)
{ {
u32 block = (u32)(offset / header.block_size); u32 block = (u32)(offset / header.block_size);
u32 data_offset = offset % header.block_size; u32 data_offset = offset % header.block_size;
u32 bytes_to_read = (u32)min((u64)(header.block_size - data_offset), nbytes); u32 bytes_to_read = (u32)min((u64)(header.block_size - data_offset), nbytes);
if ((block >= CISO_MAP_SIZE) || (ciso_map[block] == CISO_UNUSED_BLOCK)) if ((block >= CISO_MAP_SIZE) || (ciso_map[block] == CISO_UNUSED_BLOCK))
{ {
memset(out_ptr, 0, bytes_to_read); memset(out_ptr, 0, bytes_to_read);
out_ptr += bytes_to_read; out_ptr += bytes_to_read;
offset += bytes_to_read; offset += bytes_to_read;
bytesRead += bytes_to_read; bytesRead += bytes_to_read;
} }
else else
{ {
// calcualte the base address // calcualte the base address
u64 file_off = CISO_HEAD_SIZE + ciso_map[block] * (u64)header.block_size + data_offset; u64 file_off = CISO_HEAD_SIZE + ciso_map[block] * (u64)header.block_size + data_offset;
if (fseeko(file_, (long)file_off, SEEK_SET) != 0) if (fseeko(file_, (long)file_off, SEEK_SET) != 0)
return false; return false;
if (fread(out_ptr, 1, bytes_to_read, file_) != bytes_to_read) if (fread(out_ptr, 1, bytes_to_read, file_) != bytes_to_read)
return false; return false;
out_ptr += bytes_to_read; out_ptr += bytes_to_read;
offset += bytes_to_read; offset += bytes_to_read;
bytesRead += bytes_to_read; bytesRead += bytes_to_read;
} }
} }
return true; return true;
} }
bool IsCISOBlob(const char* filename) bool IsCISOBlob(const char* filename)
{ {
FILE* f = fopen(filename, "rb"); FILE* f = fopen(filename, "rb");
if (!f) if (!f)
return false; return false;
CISO_Head_t header; CISO_Head_t header;
fread(&header, sizeof(header), 1, f); fread(&header, sizeof(header), 1, f);
fclose(f); fclose(f);
return (memcmp(header.magic, CISO_MAGIC, sizeof(header.magic)) == 0); return (memcmp(header.magic, CISO_MAGIC, sizeof(header.magic)) == 0);
} }
} // namespace } // namespace

View File

@ -1,66 +1,66 @@
// Copyright (C) 2003 Dolphin Project. // Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0. // the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details. // GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program. // A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/ // If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifndef _CISO_BLOB_H #ifndef _CISO_BLOB_H
#define _CISO_BLOB_H #define _CISO_BLOB_H
#include "Blob.h" #include "Blob.h"
#include <cstdio> #include <cstdio>
#define CISO_MAGIC "CISO" #define CISO_MAGIC "CISO"
#define CISO_HEAD_SIZE (0x8000) #define CISO_HEAD_SIZE (0x8000)
#define CISO_MAP_SIZE (CISO_HEAD_SIZE - 8) #define CISO_MAP_SIZE (CISO_HEAD_SIZE - 8)
namespace DiscIO namespace DiscIO
{ {
bool IsCISOBlob(const char* filename); bool IsCISOBlob(const char* filename);
// Blocks that won't compress to less than 97% of the original size are stored as-is. // Blocks that won't compress to less than 97% of the original size are stored as-is.
typedef struct CISO_Head_t typedef struct CISO_Head_t
{ {
u8 magic[4]; // "CISO" u8 magic[4]; // "CISO"
u32 block_size; // stored as litte endian (not network byte order) u32 block_size; // stored as litte endian (not network byte order)
u8 map[CISO_MAP_SIZE]; // 0=unused, 1=used, others=invalid u8 map[CISO_MAP_SIZE]; // 0=unused, 1=used, others=invalid
} CISO_Head_t; } CISO_Head_t;
typedef u16 CISO_Map_t; typedef u16 CISO_Map_t;
const CISO_Map_t CISO_UNUSED_BLOCK = (CISO_Map_t)~0; const CISO_Map_t CISO_UNUSED_BLOCK = (CISO_Map_t)~0;
class CISOFileReader : public IBlobReader class CISOFileReader : public IBlobReader
{ {
FILE* file_; FILE* file_;
CISOFileReader(FILE* file__); CISOFileReader(FILE* file__);
s64 size; s64 size;
public: public:
static CISOFileReader* Create(const char* filename); static CISOFileReader* Create(const char* filename);
~CISOFileReader(); ~CISOFileReader();
u64 GetDataSize() const { return size; } u64 GetDataSize() const { return size; }
u64 GetRawSize() const { return size; } u64 GetRawSize() const { return size; }
bool Read(u64 offset, u64 nbytes, u8* out_ptr); bool Read(u64 offset, u64 nbytes, u8* out_ptr);
private: private:
CISO_Head_t header; CISO_Head_t header;
CISO_Map_t ciso_map[CISO_MAP_SIZE]; CISO_Map_t ciso_map[CISO_MAP_SIZE];
}; };
} // namespace } // namespace
#endif // _FILE_BLOB_H #endif // _FILE_BLOB_H