/* -*- mode: C++; tab-width: 4 -*- */ /* ===================================================================== *\ Copyright (c) 2000-2001 Palm, Inc. or its subsidiaries. All rights reserved. This file is part of the Palm OS Emulator. 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. \* ===================================================================== */ #include "EmCommon.h" #include "EmTRGDiskIO.h" /************************************************************************ * This class handles the generic low level disk access. ************************************************************************/ #include #include "EmCommon.h" #include "EmTRGDiskIO.h" #define CFFILE_NAME "trgdrv.dat" #define SDFILE_NAME "trgdrvsd.dat" #define SECTOR_SIZE 512 EmTRGDiskIO::EmTRGDiskIO() { m_driveNo = UNKNOWN_DRIVE; } EmTRGDiskIO::~EmTRGDiskIO() { } char * EmTRGDiskIO::GetFilePath(int driveNo) { #if PLATFORM_WINDOWS static char tmp[MAX_PATH]; if (driveNo == CF_DRIVE) _snprintf(tmp, sizeof(tmp), "%s\\%s", getenv("WINDIR"), CFFILE_NAME); else _snprintf(tmp, sizeof(tmp), "%s\\%s", getenv("WINDIR"), SDFILE_NAME); return(tmp); #else if (driveNo == CF_DRIVE) return CFFILE_NAME; else return SDFILE_NAME; #endif } int EmTRGDiskIO::Format(void) { EmSector *buffer; uint32 num, lba; FILE *fp; fp = fopen(GetFilePath(m_driveNo), "wb"); if (fp == NULL) return -1; buffer = new EmSector; num = m_currDisk.GetNumSectors(m_diskTypeID); for (lba=0; lba