mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
1 line
70 KiB
C
1 line
70 KiB
C
|
|
/****************************************************************************
The Disc Image Chef
-----------------------------------------------------------------------------
Filename : macos.c
Author(s) : Natalia Portillo
Component : fstester.setter
--[ Description ] -----------------------------------------------------------
Contains Mac OS code
--[ License ] ---------------------------------------------------------------
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 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warraty of
MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2018 Natalia Portillo
*****************************************************************************/
#if defined(macintosh)
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <Gestalt.h>
#include <Files.h>
#include <TextUtils.h>
#include <MacTypes.h>
#include <Aliases.h>
#include <Resources.h>
#include <FileTypesAndCreators.h>
#include "consts.h"
#include "defs.h"
#include "macos.h"
void GetOsInfo()
{
int32_t gestaltResponse;
OSErr rc;
printf("OS information:\n");
rc = Gestalt(gestaltAUXVersion, &gestaltResponse);
if(!rc)
{
printf("Running under A/UX version 0x%08X\n", gestaltResponse);
}
else
{
rc = Gestalt(gestaltSystemVersion, &gestaltResponse);
if(rc)
{
printf("Could not get Mac OS version.\n");
}
else
{
printf("Running under Mac OS version %d.%d.%d", (gestaltResponse & 0xF00) >> 8,
(gestaltResponse & 0xF0) >> 4, gestaltResponse & 0xF);
rc = Gestalt(gestaltSysArchitecture, &gestaltResponse);
if(!rc)
{
printf(" for ");
switch(gestaltResponse)
{
case 1:
printf("Motorola 68k architecture.");
break;
case 2:
printf("PowerPC architecture.");
break;
case 3:
printf("x86 architecture.");
break;
default:
printf("unknown architecture code %d.", gestaltResponse);
break;
}
}
printf("\n");
}
rc = Gestalt(gestaltMacOSCompatibilityBoxAttr, &gestaltResponse);
if(!rc)
{
printf("Running under Classic.\n");
}
}
}
void GetVolumeInfo(const char *path, size_t *clusterSize)
{
OSErr rc;
Str255 str255;
HVolumeParam hpb;
XVolumeParam xpb;
int32_t gestaltResponse;
int16_t drvInfo;
int16_t refNum;
uint64_t totalBlocks;
uint64_t freeBlocks;
uint32_t crDate;
uint32_t lwDate;
uint32_t bkDate;
uint16_t fsId;
uint64_t totalBytes;
uint64_t freeBytes;
int hfsPlusApis = 0;
int bigVol = 0;
*clusterSize = 0;
snprintf((char *)str255, 255, "%s", path);
rc = Gestalt(gestaltFSAttr, &gestaltResponse);
if(!rc)
{
hfsPlusApis = gestaltResponse & (1 << gestaltHasHFSPlusAPIs);
bigVol = gestaltResponse & (1 << gestaltFSSupports2TBVols);
}
if(!bigVol)
{
hpb.ioNamePtr = str255;
hpb.ioVRefNum = 0;
hpb.ioVolIndex = -1;
rc = PB
|