mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Implement links for Atari ST.
This commit is contained in:
@@ -22,8 +22,75 @@ Aaru Data Preservation Suite
|
|||||||
Copyright (C) 2011-2021 Natalia Portillo
|
Copyright (C) 2011-2021 Natalia Portillo
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <eti.h>
|
||||||
|
#include <mint/cookie.h>
|
||||||
|
#include <mint/mintbind.h>
|
||||||
|
#include <mint/osbind.h>
|
||||||
|
#include <mint/sysvars.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../include/defs.h"
|
#include "../include/defs.h"
|
||||||
|
#include "../log.h"
|
||||||
|
|
||||||
void Links(const char* path)
|
void Links(const char* path)
|
||||||
{ // TODO: MiNT. MagiC?
|
{
|
||||||
|
long** cookieJar = _p_cookies;
|
||||||
|
long cookie;
|
||||||
|
int rc;
|
||||||
|
FILE* h;
|
||||||
|
char driveNo = path[0] - '@';
|
||||||
|
|
||||||
|
// Check for a cookie jar
|
||||||
|
if(*cookieJar == 0) return;
|
||||||
|
|
||||||
|
// Check if MiNT or MagiC
|
||||||
|
rc = (Getcookie(C_MiNT, &cookie) == E_OK) || (Getcookie(C_MagX, &cookie) == E_OK) ||
|
||||||
|
(Getcookie(C_MgMc, &cookie) == E_OK) || (Getcookie(C_MgMx, &cookie) == E_OK) ||
|
||||||
|
(Getcookie(C_MgPC, &cookie) == E_OK);
|
||||||
|
|
||||||
|
if(rc == 0) return;
|
||||||
|
|
||||||
|
if(driveNo > 32) driveNo -= 32;
|
||||||
|
|
||||||
|
Dsetdrv(driveNo);
|
||||||
|
Dsetpath("\\");
|
||||||
|
|
||||||
|
rc = Dcreate("LINKS");
|
||||||
|
|
||||||
|
if(rc != E_OK)
|
||||||
|
{
|
||||||
|
log_write("Error %d creating working directory.\n", rc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = Dsetpath("LINKS");
|
||||||
|
|
||||||
|
if(rc != E_OK)
|
||||||
|
{
|
||||||
|
log_write("Error %d changing to working directory.\n", rc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_write("Creating links.\n");
|
||||||
|
|
||||||
|
h = fopen("TARGET", "w+");
|
||||||
|
|
||||||
|
if(h == NULL)
|
||||||
|
{
|
||||||
|
log_write("Error %d creating target file.\n", errno);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(h, "This is the target for the links.\n");
|
||||||
|
|
||||||
|
fclose(h);
|
||||||
|
|
||||||
|
rc = Flink("TARGET", "HARD");
|
||||||
|
|
||||||
|
if(rc != E_OK) log_write("Error %d creating hard link.\n", errno);
|
||||||
|
|
||||||
|
rc = Fsymlink("TARGET", "SYMBOLIC");
|
||||||
|
|
||||||
|
if(rc != E_OK) log_write("Error %d creating symbolic link.\n", errno);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user