need a test for volume/directory calls

This commit is contained in:
Kelvin Sherlock 2015-01-15 16:39:10 -05:00
parent 3448078612
commit acea989367
2 changed files with 68 additions and 12 deletions

View File

@ -1,3 +1,10 @@
# ignore built-in rules, don't delete intermediate .o files.
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
.SECONDARY:
LIBS = \
{Libraries}Stubs.o \
{CLibraries}StdCLib.o \
@ -15,26 +22,29 @@ LDFLAGS = -w -c 'MPS ' -t MPST \
SCFLAGS = -p
TARGETS = test_new_handle test_new_handle_2 test_new_pointer
TARGETS = test_new_handle test_new_handle_2 test_new_pointer test_volumes
all : $(TARGETS)
clean :
rm -f $(TARGETS) o/*
test_new_handle : o/test_new_handle.o
mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
test_new_handle_2 : o/test_new_handle_2.o
mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
test_new_pointer : o/test_new_pointer.o
mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
# % : o/%.o
# test_new_handle : o/test_new_handle.o
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
# test_new_handle_2 : o/test_new_handle_2.o
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
# test_new_pointer : o/test_new_pointer.o
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
# test_volumes : o/test_volumes.o
# mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
% : o/%.o
mpw Link $(LDFLAGS) -o $@ $^ $(LIBS)
o/%.o : %.c
mpw SC $(SCFLAGS) $< -o $@

46
test/test_volumes.c Normal file
View File

@ -0,0 +1,46 @@
#include <Files.h>
#include <stdio.h>
#include <string.h>
void gv(StringPtr name)
{
OSErr err;
short vRefNum;
err = GetVol(name, &vRefNum);
if (err) fprintf(stdout, "GetVol(%s): Error = %d\n", name ? name + 1 : (StringPtr)"", err);
else fprintf(stdout, "GetVol(%s): vRefNum = %d\n", name ? name + 1 : (StringPtr)"", vRefNum);
}
void hgv(StringPtr name)
{
OSErr err;
short vRefNum;
long dirID;
err = HGetVol(name, &vRefNum, &dirID);
if (err) fprintf(stdout, "HGetVol(%s): Error = %d\n", name ? name + 1 : (StringPtr)"", err);
else fprintf(stdout, "HGetVol(%s): vRefNum = %d dirID = %d\n",
name ? name + 1 : (StringPtr)"", vRefNum, dirID);
}
int main(int argc, char **argv)
{
(void)argc;
(void)argv;
gv(NULL);
gv((StringPtr)"\pMacOS");
hgv(NULL);
hgv((StringPtr)"\pMacOS");
return 0;
}