mirror of
https://github.com/Halofreak1990/XFXFramework
synced 2024-12-26 13:49:34 +01:00
Removed BeginRead and BeginWrite from Stream class; finally got it to compile :)
Now, there's only fixing cross-references and getting the namespace include headers sorted out. (Tech demo won't compile otherwise)
This commit is contained in:
parent
1c277b2038
commit
95f3ff3ab6
@ -4,8 +4,8 @@
|
|||||||
* XFX Directory class definition file *
|
* XFX Directory class definition file *
|
||||||
* Copyright © XFX Team. All Rights Reserved *
|
* Copyright © XFX Team. All Rights Reserved *
|
||||||
********************************************************/
|
********************************************************/
|
||||||
#ifndef _IO_DIRECTORY_
|
#ifndef _SYSTEM_IO_DIRECTORY_
|
||||||
#define _IO_DIRECTORY_
|
#define _SYSTEM_IO_DIRECTORY_
|
||||||
|
|
||||||
#include "../Types.h"
|
#include "../Types.h"
|
||||||
|
|
||||||
@ -48,4 +48,4 @@ namespace System
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //_IO_DIRECTORY_
|
#endif //_SYSTEM_IO_DIRECTORY_
|
||||||
|
@ -32,13 +32,13 @@ namespace System
|
|||||||
DirectoryInfo Parent();
|
DirectoryInfo Parent();
|
||||||
DirectoryInfo Root();
|
DirectoryInfo Root();
|
||||||
|
|
||||||
DirectoryInfo(const char* path, bool junk);
|
DirectoryInfo(const char* path); // Initializes a new instance of the System::IO::DirectoryInfo class on the specified path.
|
||||||
|
|
||||||
void Create();
|
void Create(); // Creates a directory.
|
||||||
DirectoryInfo CreateSubDirectory(const char* path);
|
DirectoryInfo CreateSubDirectory(const char* path); // Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the System::IO::DirectoryInfo class.
|
||||||
void Delete();
|
void Delete(); // Deletes this System::IO::DirectoryInfo if it is empty.
|
||||||
void Delete(bool recursive);
|
void Delete(bool recursive); // Deletes this instance of a System::IO::DirectoryInfo, specifying whether to delete subdirectories and files.
|
||||||
DirectoryInfo* GetDirectories();
|
DirectoryInfo* GetDirectories(); //
|
||||||
DirectoryInfo* GetDirectories(const char* searchPattern);
|
DirectoryInfo* GetDirectories(const char* searchPattern);
|
||||||
FileSystemInfo* GetFileSystemInfos();
|
FileSystemInfo* GetFileSystemInfos();
|
||||||
FileSystemInfo* GetFileSystemInfos(const char* searchPattern);
|
FileSystemInfo* GetFileSystemInfos(const char* searchPattern);
|
||||||
|
@ -7,6 +7,10 @@ namespace System
|
|||||||
{
|
{
|
||||||
class FileSystemInfo
|
class FileSystemInfo
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
char* FullPath;
|
||||||
|
char* OriginalPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual char* FullName();
|
virtual char* FullName();
|
||||||
};
|
};
|
||||||
|
@ -43,12 +43,8 @@ namespace System
|
|||||||
int WriteTimeOut;
|
int WriteTimeOut;
|
||||||
static const Stream Null;
|
static const Stream Null;
|
||||||
|
|
||||||
virtual IAsyncResult* BeginRead(byte buffer[], int offset, int count, ASyncCallback callback, Object* state);
|
|
||||||
virtual IAsyncResult* BeginWrite(byte buffer[], int offset, int count, ASyncCallback callback, Object* state);
|
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
void Dispose();
|
void Dispose();
|
||||||
virtual int EndRead(IAsyncResult* asyncResult);
|
|
||||||
virtual void EndWrite(IAsyncResult* asyncResult);
|
|
||||||
virtual void Flush();
|
virtual void Flush();
|
||||||
virtual int Read(byte buffer[], int offset, int count);
|
virtual int Read(byte buffer[], int offset, int count);
|
||||||
virtual int ReadByte();
|
virtual int ReadByte();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define _SYSTEM_STRING_
|
#define _SYSTEM_STRING_
|
||||||
|
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include <System/Types.h>
|
#include "Types.h"
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
@ -50,6 +50,7 @@ namespace System
|
|||||||
int IndexOf(char value, int startIndex);
|
int IndexOf(char value, int startIndex);
|
||||||
int IndexOf(char value, int startIndex, int count);
|
int IndexOf(char value, int startIndex, int count);
|
||||||
static bool IsNullOrEmpty(String value);
|
static bool IsNullOrEmpty(String value);
|
||||||
|
static bool IsNullOrEmpty(char* value);
|
||||||
static String Join(String &separator, String value[]);
|
static String Join(String &separator, String value[]);
|
||||||
static String Join(String &separator, String value[], int startIndex, int count);
|
static String Join(String &separator, String value[], int startIndex, int count);
|
||||||
String PadLeft(int totalWidth);
|
String PadLeft(int totalWidth);
|
||||||
@ -65,7 +66,7 @@ namespace System
|
|||||||
char** Split(char separator[], int count);
|
char** Split(char separator[], int count);
|
||||||
char** Split(char separator[]);
|
char** Split(char separator[]);
|
||||||
bool StartsWith(char* value);
|
bool StartsWith(char* value);
|
||||||
String SubString(int startIndex);
|
static char* SubString(int startIndex);
|
||||||
String SubString(int startIndex, int length);
|
String SubString(int startIndex, int length);
|
||||||
char *ToCharArray(int startIndex, int length);
|
char *ToCharArray(int startIndex, int length);
|
||||||
char *ToCharArray();
|
char *ToCharArray();
|
||||||
@ -74,6 +75,7 @@ namespace System
|
|||||||
String ToUpper();
|
String ToUpper();
|
||||||
|
|
||||||
bool operator!=(const String right);
|
bool operator!=(const String right);
|
||||||
|
bool operator!=(const char* right);
|
||||||
bool operator==(const String right);
|
bool operator==(const String right);
|
||||||
bool operator==(const char* right);
|
bool operator==(const char* right);
|
||||||
String operator=(const char* right);
|
String operator=(const char* right);
|
||||||
|
@ -1,3 +1,30 @@
|
|||||||
|
// Copyright (C) 2010-2012, Halofreak_1990
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in the
|
||||||
|
// documentation and/or other materials provided with the distribution.
|
||||||
|
// * Neither the name of the copyright holder nor the names of any
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <System/DateTime.h>
|
#include <System/DateTime.h>
|
||||||
#include <System/IO/Directory.h>
|
#include <System/IO/Directory.h>
|
||||||
#include <System/IO/DirectoryInfo.h>
|
#include <System/IO/DirectoryInfo.h>
|
||||||
@ -6,10 +33,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
|
||||||
#include <hal/fileio.h>
|
#include <hal/fileio.h>
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
@ -23,10 +47,9 @@ namespace System
|
|||||||
if (File::Exists(path))
|
if (File::Exists(path))
|
||||||
throw IOException(strcat((char*)"Cannot create ", strcat(path,(char*)" because a file with the same name already exists.")));
|
throw IOException(strcat((char*)"Cannot create ", strcat(path,(char*)" because a file with the same name already exists.")));
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
|
||||||
XCreateDirectory(path);
|
XCreateDirectory(path);
|
||||||
#else
|
|
||||||
#endif
|
return DirectoryInfo(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Directory::Delete(char* path)
|
void Directory::Delete(char* path)
|
||||||
@ -36,9 +59,7 @@ namespace System
|
|||||||
|
|
||||||
void Directory::Delete(char* path, bool recursive)
|
void Directory::Delete(char* path, bool recursive)
|
||||||
{
|
{
|
||||||
#if ENABLE_XBOX
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Directory::Exists(char* path)
|
bool Directory::Exists(char* path)
|
||||||
|
84
src/libmscorlib/DirectoryInfo.cpp
Normal file
84
src/libmscorlib/DirectoryInfo.cpp
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Copyright (C) 2010-2012, Halofreak_1990
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in the
|
||||||
|
// documentation and/or other materials provided with the distribution.
|
||||||
|
// * Neither the name of the copyright holder nor the names of any
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include <System/IO/Directory.h>
|
||||||
|
#include <System/IO/DirectoryInfo.h>
|
||||||
|
#include <System/IO/IOException.h>
|
||||||
|
#include <System/String.h>
|
||||||
|
|
||||||
|
namespace System
|
||||||
|
{
|
||||||
|
namespace IO
|
||||||
|
{
|
||||||
|
DirectoryInfo::DirectoryInfo(const char* path)
|
||||||
|
{
|
||||||
|
if (path == null)
|
||||||
|
throw ArgumentNullException("path");
|
||||||
|
|
||||||
|
if ((String::Length() == 2) && (path[1] == ':'))
|
||||||
|
{
|
||||||
|
OriginalPath = ".";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OriginalPath = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirectoryInfo::Create()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectoryInfo DirectoryInfo::CreateSubDirectory(const char* path)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirectoryInfo::Delete()
|
||||||
|
{
|
||||||
|
Directory::Delete(FullPath, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirectoryInfo::Delete(bool recursive)
|
||||||
|
{
|
||||||
|
Directory::Delete(FullPath, recursive);
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectoryInfo* DirectoryInfo::GetDirectories()
|
||||||
|
{
|
||||||
|
return GetDirectories("*");
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectoryInfo* DirectoryInfo::GetDirectories(const char* searchPattern)
|
||||||
|
{
|
||||||
|
if (searchPattern = null)
|
||||||
|
throw ArgumentNullException("searchPattern");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,8 +33,7 @@
|
|||||||
#include <System/IO/StreamReader.h>
|
#include <System/IO/StreamReader.h>
|
||||||
#include <System/IO/StreamWriter.h>
|
#include <System/IO/StreamWriter.h>
|
||||||
#include <hal/fileio.h>
|
#include <hal/fileio.h>
|
||||||
|
#include <xboxkrnl/xboxkrnl.h>
|
||||||
extern void *malloc(unsigned int size);
|
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
@ -72,16 +71,16 @@ namespace System
|
|||||||
int sourceHandle;
|
int sourceHandle;
|
||||||
int destHandle;
|
int destHandle;
|
||||||
UInt32 length;
|
UInt32 length;
|
||||||
byte *buffer;
|
void *buffer;
|
||||||
ret = XCreateFile(&sourceHandle, sourceFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
|
ret = XCreateFile(&sourceHandle, sourceFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
{
|
{
|
||||||
XGetFileSize(sourceHandle, &length);
|
XGetFileSize(sourceHandle, &length);
|
||||||
buffer = (byte*)malloc((int)length);
|
buffer = MmAllocateContiguousMemory((int)length);
|
||||||
XReadFile(sourceHandle, (void*)buffer, length, NULL);
|
XReadFile(sourceHandle, buffer, length, NULL);
|
||||||
XCloseHandle(sourceHandle);
|
XCloseHandle(sourceHandle);
|
||||||
XCreateFile(&destHandle, destFileName, GENERIC_WRITE, FILE_SHARE_WRITE, CREATE_NEW, FILE_ATTRIBUTE_NORMAL);
|
XCreateFile(&destHandle, destFileName, GENERIC_WRITE, FILE_SHARE_WRITE, CREATE_NEW, FILE_ATTRIBUTE_NORMAL);
|
||||||
XWriteFile(destHandle, (void*)buffer, length, NULL);
|
XWriteFile(destHandle, buffer, length, NULL);
|
||||||
XCloseHandle(destHandle);
|
XCloseHandle(destHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,7 +113,7 @@ namespace System
|
|||||||
|
|
||||||
bool File::Exists(char* path)
|
bool File::Exists(char* path)
|
||||||
{
|
{
|
||||||
bool flag;
|
bool flag = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(path == null)
|
if(path == null)
|
||||||
@ -124,7 +123,7 @@ namespace System
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
path = Path::GetFullPath(path);
|
path = Path::GetFullPath(path);
|
||||||
PXBOX_FIND_DATA data;
|
PXBOX_FIND_DATA data = null;
|
||||||
flag = ((FileAttributeInfo(path, data, false, false) == 0) && (data->dwFileAttributes != -1) && ((data->dwFileAttributes & 0x10) == 0));
|
flag = ((FileAttributeInfo(path, data, false, false) == 0) && (data->dwFileAttributes != -1) && ((data->dwFileAttributes & 0x10) == 0));
|
||||||
}
|
}
|
||||||
catch(ArgumentException)
|
catch(ArgumentException)
|
||||||
@ -175,6 +174,7 @@ namespace System
|
|||||||
char* dst = Path::GetFullPath(destFileName);
|
char* dst = Path::GetFullPath(destFileName);
|
||||||
|
|
||||||
//! TODO: Move the file
|
//! TODO: Move the file
|
||||||
|
// I suspect MoveFile is simply copying the file, and then removing the source file.
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream File::Open(char* path, FileMode_t mode)
|
FileStream File::Open(char* path, FileMode_t mode)
|
||||||
|
@ -28,12 +28,10 @@
|
|||||||
#include <System/IO/FileStream.h>
|
#include <System/IO/FileStream.h>
|
||||||
#include <System/IO/IOException.h>
|
#include <System/IO/IOException.h>
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
extern "C"
|
||||||
extern "C" {
|
{
|
||||||
#include <hal/fileio.h>
|
#include <hal/fileio.h>
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
@ -63,11 +61,9 @@ namespace System
|
|||||||
throw NotSupportedException("The stream does not support seeking.");
|
throw NotSupportedException("The stream does not support seeking.");
|
||||||
|
|
||||||
Int64 length;
|
Int64 length;
|
||||||
#if ENABLE_XBOX
|
|
||||||
if(XGetFileSize(handle, (unsigned int *)length) != STATUS_SUCCESS)
|
if(XGetFileSize(handle, (unsigned int *)length) != STATUS_SUCCESS)
|
||||||
throw IOException("Could not determine file size. The file may be corrupt.");
|
throw IOException("Could not determine file size. The file may be corrupt.");
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
if ((_writePos > 0) && ((_pos + _writePos) > length))
|
if ((_writePos > 0) && ((_pos + _writePos) > length))
|
||||||
{
|
{
|
||||||
length = _writePos + _pos;
|
length = _writePos + _pos;
|
||||||
@ -108,10 +104,8 @@ namespace System
|
|||||||
throw ArgumentNullException("path", "path was either NULL or an empty string.");
|
throw ArgumentNullException("path", "path was either NULL or an empty string.");
|
||||||
|
|
||||||
_access = (mode == FileMode::Append ? FileAccess::Write : FileAccess::ReadWrite);
|
_access = (mode == FileMode::Append ? FileAccess::Write : FileAccess::ReadWrite);
|
||||||
#if ENABLE_XBOX
|
|
||||||
XCreateFile(&handle, path, _access, FileShare::Read, mode, FILE_ATTRIBUTE_NORMAL);
|
XCreateFile(&handle, path, _access, FileShare::Read, mode, FILE_ATTRIBUTE_NORMAL);
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream::FileStream(char* path, FileMode_t mode, FileAccess_t access)
|
FileStream::FileStream(char* path, FileMode_t mode, FileAccess_t access)
|
||||||
@ -120,10 +114,8 @@ namespace System
|
|||||||
throw ArgumentNullException("path", "path was either NULL, or an empty string.");
|
throw ArgumentNullException("path", "path was either NULL, or an empty string.");
|
||||||
|
|
||||||
_access = access;
|
_access = access;
|
||||||
#if ENABLE_XBOX
|
|
||||||
XCreateFile(&handle, path, access, FILE_SHARE_READ | FILE_SHARE_WRITE, mode, FILE_ATTRIBUTE_NORMAL);
|
XCreateFile(&handle, path, access, FILE_SHARE_READ | FILE_SHARE_WRITE, mode, FILE_ATTRIBUTE_NORMAL);
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream::FileStream(char* path, FileMode_t mode, FileAccess_t access, FileShare_t share)
|
FileStream::FileStream(char* path, FileMode_t mode, FileAccess_t access, FileShare_t share)
|
||||||
@ -131,10 +123,7 @@ namespace System
|
|||||||
if(path == null || path == "")
|
if(path == null || path == "")
|
||||||
throw ArgumentNullException("path", "path was either NULL, or an empty string.");
|
throw ArgumentNullException("path", "path was either NULL, or an empty string.");
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
|
||||||
XCreateFile(&handle, path, access, share, mode, FILE_ATTRIBUTE_NORMAL);
|
XCreateFile(&handle, path, access, share, mode, FILE_ATTRIBUTE_NORMAL);
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream::FileStream(char* path, FileMode_t mode, FileAccess_t access, FileShare_t share, int bufferSize)
|
FileStream::FileStream(char* path, FileMode_t mode, FileAccess_t access, FileShare_t share, int bufferSize)
|
||||||
@ -147,18 +136,7 @@ namespace System
|
|||||||
if (bufferSize <= 0)
|
if (bufferSize <= 0)
|
||||||
throw ArgumentOutOfRangeException("bufferSize", "Positive number required.");
|
throw ArgumentOutOfRangeException("bufferSize", "Positive number required.");
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
XCreateFile(&handle, path, access, share, mode, FILE_ATTRIBUTE_NORMAL);
|
||||||
isAsync = useAsync;
|
|
||||||
|
|
||||||
if(isAsync)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XCreateFile(&handle, path, access, share, mode, FILE_ATTRIBUTE_NORMAL);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream::~FileStream()
|
FileStream::~FileStream()
|
||||||
@ -204,18 +182,7 @@ namespace System
|
|||||||
|
|
||||||
void FileStream::FlushWrite(bool calledFromFinalizer)
|
void FileStream::FlushWrite(bool calledFromFinalizer)
|
||||||
{
|
{
|
||||||
if (isAsync)
|
Write(_buffer, 0, _writePos);
|
||||||
{
|
|
||||||
IAsyncResult* asyncResult = BeginWrite(_buffer, 0, _writePos, null, null);
|
|
||||||
if (!calledFromFinalizer)
|
|
||||||
{
|
|
||||||
EndWrite(asyncResult);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Write(_buffer, 0, _writePos);
|
|
||||||
}
|
|
||||||
_writePos = 0;
|
_writePos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,18 +208,9 @@ namespace System
|
|||||||
if (offset > len - count)
|
if (offset > len - count)
|
||||||
throw ArgumentException("Reading would overrun buffer");
|
throw ArgumentException("Reading would overrun buffer");
|
||||||
|
|
||||||
if(isAsync)
|
|
||||||
{
|
|
||||||
IAsyncResult* ares = BeginRead(array, offset, count, null, null);
|
|
||||||
return EndRead(ares);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
|
||||||
UInt32 bytesRead;
|
UInt32 bytesRead;
|
||||||
XReadFile(handle, &array[offset], count, &bytesRead);
|
XReadFile(handle, &array[offset], count, &bytesRead);
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int FileStream::ReadByte()
|
int FileStream::ReadByte()
|
||||||
@ -272,7 +230,6 @@ namespace System
|
|||||||
if(handle == -1)
|
if(handle == -1)
|
||||||
throw ObjectDisposedException("FileStream", "The stream has been closed.");
|
throw ObjectDisposedException("FileStream", "The stream has been closed.");
|
||||||
|
|
||||||
#if ENABLE_XBOX
|
|
||||||
FILE_POSITION_INFORMATION positionInfo;
|
FILE_POSITION_INFORMATION positionInfo;
|
||||||
LARGE_INTEGER targetPointer;
|
LARGE_INTEGER targetPointer;
|
||||||
IO_STATUS_BLOCK ioStatusBlock;
|
IO_STATUS_BLOCK ioStatusBlock;
|
||||||
@ -311,8 +268,6 @@ namespace System
|
|||||||
{
|
{
|
||||||
return targetPointer.QuadPart;
|
return targetPointer.QuadPart;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStream::SetLength(long long value)
|
void FileStream::SetLength(long long value)
|
||||||
@ -328,34 +283,18 @@ namespace System
|
|||||||
|
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
if (Position() > value)
|
if (Position() > value)
|
||||||
Position(value);
|
Position(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStream::Write(byte array[], int offset, int count)
|
void FileStream::Write(byte array[], int offset, int count)
|
||||||
{
|
{
|
||||||
if(isAsync)
|
|
||||||
{
|
|
||||||
IAsyncResult* asyncResult = BeginWrite(array, offset, count, null, null);
|
|
||||||
EndWrite(asyncResult);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if ENABLE_XBOX
|
|
||||||
XWriteFile(handle, &array[offset], count, null);
|
XWriteFile(handle, &array[offset], count, null);
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileStream::WriteByte(byte value)
|
void FileStream::WriteByte(byte value)
|
||||||
{
|
{
|
||||||
#if ENABLE_XBOX
|
|
||||||
XWriteFile(handle, (void*)value, 1, null);
|
XWriteFile(handle, (void*)value, 1, null);
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,8 @@ namespace System
|
|||||||
{
|
{
|
||||||
namespace IO
|
namespace IO
|
||||||
{
|
{
|
||||||
#if ENABLE_XBOX // The XBOX Limits us to 64MB; we do not take XDKs into account
|
// The XBOX Limits us to 64MB; we do not take XDK/Debug units into account
|
||||||
const int MemoryStream::MemStreamMaxLength = 0x40000000;
|
const int MemoryStream::MemStreamMaxLength = 0x40000000;
|
||||||
#else
|
|
||||||
const int MemoryStream::MemStreamMaxLength = 0x7fffffff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool MemoryStream::CanRead()
|
bool MemoryStream::CanRead()
|
||||||
{
|
{
|
||||||
@ -132,6 +129,7 @@ namespace System
|
|||||||
}
|
}
|
||||||
_buffer = buffer;
|
_buffer = buffer;
|
||||||
_length = _capacity = Array::Length(buffer);
|
_length = _capacity = Array::Length(buffer);
|
||||||
|
_expandable = false;
|
||||||
_writable = true;
|
_writable = true;
|
||||||
_exposable = false;
|
_exposable = false;
|
||||||
_origin = 0;
|
_origin = 0;
|
||||||
|
@ -43,46 +43,6 @@ namespace System
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IAsyncResult* Stream::BeginRead(byte buffer[], int offset, int count, ASyncCallback callback, Object* state)
|
|
||||||
{
|
|
||||||
if(!CanRead())
|
|
||||||
throw NotSupportedException("This stream does not support reading");
|
|
||||||
|
|
||||||
StreamAsyncResult result = StreamAsyncResult(state);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int nbytes = Read(buffer, offset, count);
|
|
||||||
result.SetComplete(null, nbytes);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
result.SetComplete(&e, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
IAsyncResult* Stream::BeginWrite(byte buffer[], int offset, int count, ASyncCallback callback, Object* state)
|
|
||||||
{
|
|
||||||
if(!CanWrite())
|
|
||||||
throw NotSupportedException("This stream does not support writing");
|
|
||||||
|
|
||||||
StreamAsyncResult result = StreamAsyncResult(state);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Write (buffer, offset, count);
|
|
||||||
result.SetComplete(null);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
result.SetComplete(&e);
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stream::Close()
|
void Stream::Close()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
@ -93,36 +53,6 @@ namespace System
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Stream::EndRead(IAsyncResult* asyncResult)
|
|
||||||
{
|
|
||||||
StreamAsyncResult result = (StreamAsyncResult)asyncResult;
|
|
||||||
if (result.NBytes() == -1)
|
|
||||||
throw ArgumentException("Invalid IAsyncResult", "asyncResult");
|
|
||||||
|
|
||||||
if (result.Done)
|
|
||||||
throw InvalidOperationException("EndRead already called.");
|
|
||||||
|
|
||||||
result.Done = true;
|
|
||||||
if (result.Exception_() != null)
|
|
||||||
throw result.Exception_();
|
|
||||||
|
|
||||||
return result.NBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stream::EndWrite(IAsyncResult* asyncResult)
|
|
||||||
{
|
|
||||||
StreamAsyncResult result = (StreamAsyncResult)asyncResult;
|
|
||||||
if (result.NBytes() != -1)
|
|
||||||
throw ArgumentException("Invalid IAsyncResult", "asyncResult");
|
|
||||||
|
|
||||||
if (result.Done)
|
|
||||||
throw InvalidOperationException("EndWrite already called.");
|
|
||||||
|
|
||||||
result.Done = true;
|
|
||||||
if (result.Exception_() != null)
|
|
||||||
throw result.Exception_();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Stream::ReadByte()
|
int Stream::ReadByte()
|
||||||
{
|
{
|
||||||
byte* buffer = new byte[1];
|
byte* buffer = new byte[1];
|
||||||
|
@ -191,6 +191,10 @@
|
|||||||
RelativePath=".\Directory.cpp"
|
RelativePath=".\Directory.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\DirectoryInfo.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\File.cpp"
|
RelativePath=".\File.cpp"
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user