1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 02:51:27 +00:00

Kill off pnAcFile entirely.

This commit is contained in:
Darryl Pogue
2012-03-04 15:40:17 -08:00
parent 0973bd954a
commit d1da655fb2
14 changed files with 1 additions and 2707 deletions

View File

@ -64,174 +64,6 @@ typedef struct AsyncCancelIdStruct * AsyncCancelId;
const unsigned kAsyncSocketBufferSize = 1460;
enum EFileError {
kFileSuccess,
kFileErrorInvalidParameter,
kFileErrorFileNotFound,
kFileErrorPathNotFound,
kFileErrorAccessDenied,
kFileErrorSharingViolation,
kNumFileErrors
};
EFileError AsyncGetLastFileError ();
const wchar_t * FileErrorToString (EFileError error);
/****************************************************************************
*
* File notifications
*
***/
enum EAsyncNotifyFile {
kNotifyFileFlush,
kNotifyFileRead,
kNotifyFileWrite,
kNotifyFileSequence,
kNumFileNotifications
};
struct AsyncNotifyFile {
void * param;
AsyncId asyncId;
};
struct AsyncNotifyFileConnect : AsyncNotifyFile {
uint64_t fileSize;
uint64_t fileLastWriteTime;
};
struct AsyncNotifyFileFlush : AsyncNotifyFile {
EFileError error;
uint64_t truncateSize;
};
struct AsyncNotifyFileRead : AsyncNotifyFile {
uint64_t offset;
uint8_t * buffer;
unsigned bytes;
};
typedef AsyncNotifyFileRead AsyncNotifyFileWrite;
struct AsyncNotifyFileSequence : AsyncNotifyFile {
// no additional fields
};
typedef void (* FAsyncNotifyFileProc)(
AsyncFile file,
EAsyncNotifyFile code,
AsyncNotifyFile * notify,
void ** userState
);
/****************************************************************************
*
* File I/O functions
*
***/
// Desired access
const unsigned kAsyncFileReadAccess = 0x80000000;
const unsigned kAsyncFileWriteAccess = 0x40000000;
// Open mode (creation disposition)
const unsigned kAsyncFileModeCreateNew = 1;
const unsigned kAsyncFileModeCreateAlways = 2;
const unsigned kAsyncFileModeOpenExisting = 3;
const unsigned kAsyncFileModeOpenAlways = 4;
// Share mode flags
const unsigned kAsyncFileShareRead = 0x00000001;
const unsigned kAsyncFileShareWrite = 0x00000002;
AsyncFile AsyncFileOpen (
const wchar_t fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags, // optional
void * userState, // optional
uint64_t * fileSize, // optional
uint64_t * fileLastWriteTime // optional
);
// Use with AsyncFileDelete/AsyncFileFlushBuffers
const uint64_t kAsyncFileDontTruncate = (uint64_t) -1;
// This function may ONLY be called when there is no outstanding I/O against a file
// and no more I/O will be initiated against it. This function guarantees that it
// will close the system file handle before it returns to that another open against
// the same filename can succeed.
void AsyncFileClose (
AsyncFile file,
uint64_t truncateSize
);
void AsyncFileSetLastWriteTime (
AsyncFile file,
uint64_t lastWriteTime
);
uint64_t AsyncFileGetLastWriteTime (
const wchar_t fileName[]
);
// Truncation occurs atomically, any writes which occur after
// AsyncFileFlushBuffers will be queued until the truncation completes
AsyncId AsyncFileFlushBuffers (
AsyncFile file,
uint64_t truncateSize,
bool notify,
void * param
);
const unsigned kAsyncFileRwNotify = 1<<0;
const unsigned kAsyncFileRwSync = 1<<1;
AsyncId AsyncFileRead (
AsyncFile file,
uint64_t offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
// Buffer must stay valid until I/O is completed
AsyncId AsyncFileWrite (
AsyncFile file,
uint64_t offset,
const void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
// Inserts a "null operation" into the list of reads and writes. The callback
// will be called when all preceding operations have successfully completed.
AsyncId AsyncFileCreateSequence (
AsyncFile file,
bool notify,
void * param
);
enum EFileSeekFrom {
kFileSeekFromBegin,
kFileSeekFromCurrent,
kFileSeekFromEnd,
kNumFileSeekFroms
};
bool AsyncFileSeek (
AsyncFile file,
uint64_t distance,
EFileSeekFrom seekFrom
);
/****************************************************************************
*
* Socket connect packet

View File

@ -49,79 +49,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h"
#pragma hdrstop
/*****************************************************************************
*
* Private
*
***/
static const unsigned kMaxHandlers = 8;
static CCritSect s_critsect;
static FLogHandler s_asyncHandlers[kMaxHandlers];
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static void Dispatch (ELogSeverity severity, const wchar_t msg[]) {
// Dispatch to default debug handler
char dbg[1024];
StrToAnsi(dbg, msg, arrsize(dbg));
DEBUG_MSG(dbg);
// We don't need to enter a critical section to read the handlers because they
// are atomically set and cleared
for (unsigned i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (FLogHandler asyncHandler = s_asyncHandlers[i])
asyncHandler(severity, msg);
}
}
/*****************************************************************************
*
* Exports
*
***/
//===========================================================================
void LogRegisterHandler (FLogHandler callback) {
ASSERT(callback);
unsigned i;
s_critsect.Enter();
for (i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (!s_asyncHandlers[i]) {
s_asyncHandlers[i] = callback;
break;
}
}
s_critsect.Leave();
#ifdef HS_DEBUGGING
if (i >= arrsize(s_asyncHandlers))
FATAL("Maximum number of log handlers exceeded.");
#endif
}
//===========================================================================
void LogUnregisterHandler (FLogHandler callback) {
s_critsect.Enter();
for (unsigned i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (s_asyncHandlers[i] == callback) {
s_asyncHandlers[i] = nil;
break;
}
}
s_critsect.Leave();
}
//===========================================================================
void CDECL LogMsg (ELogSeverity severity, const char format[], ...) {
ASSERT(format);

View File

@ -81,33 +81,6 @@ void LogMsg (ELogSeverity severity, const wchar_t format[], ...);
void LogMsgV (ELogSeverity severity, const char format[], va_list args);
void LogMsgV (ELogSeverity severity, const wchar_t format[], va_list args);
void LogBreakOnErrors (bool breakOnErrors);
void AsyncLogInitialize (
const wchar_t logDirName[],
bool breakOnErrors
);
void AsyncLogDestroy ();
void AsyncLogFlush ();
void AsyncLogGetDirectory (wchar_t * dest, unsigned destChars);
// Low(er) level log API; call this from your LogHander function
// if you want to use the asynchronous log facility.
void AsyncLogWriteMsg (
const wchar_t facility[],
ELogSeverity severity,
const wchar_t msg[]
);
// FLogHandler must be capable of handling multiple threads and re-entrancy
typedef void (* FLogHandler) (ELogSeverity severity, const wchar_t msg[]);
void LogRegisterHandler (FLogHandler callback);
void LogUnregisterHandler (FLogHandler callback);
/****************************************************************************
*
* Debugging API