Implement timestamps for Atari ST.

This commit is contained in:
2021-04-25 18:25:50 +01:00
parent 3e18181988
commit 9de8b4d752
3 changed files with 154 additions and 1 deletions

View File

@@ -26,4 +26,4 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "MiNT")
return()
endif()
add_sources(attr.c attr.h deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c rsrcfork.c sparse.c time.c volume.c xattr.c)
add_sources(attr.c attr.h deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c rsrcfork.c sparse.c time.c tostime.h volume.c xattr.c)

93
setter/src/atarist/time.c Normal file
View File

@@ -0,0 +1,93 @@
/****************************************************************************
Aaru Data Preservation Suite
-----------------------------------------------------------------------------
Author(s) : Natalia Portillo
--[ 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 warranty of
MERCHANTABILITY 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-2021 Natalia Portillo
*****************************************************************************/
#include <eti.h>
#include <mint/osbind.h>
#include <mint/ostruct.h>
#include <stdio.h>
#include <string.h>
#include "../include/defs.h"
#include "../log.h"
#include "tostime.h"
void Timestamps(const char* path)
{
char driveNo = path[0] - '@';
unsigned int rc, wRc = 0, cRc = 0, tRc = 0;
int handle;
char message[300];
int i;
_DOSTIME timestamp;
if(driveNo > 32) driveNo -= 32;
Dsetdrv(driveNo);
Dsetpath("\\");
rc = Dcreate("TIMES");
if(rc != E_OK)
{
log_write("Cannot create working directory.\n");
return;
}
Dsetpath("TIMES");
log_write("Creating timestamped files.\n");
for(i = 0; i < KNOWN_ATARI_TIMES; i++)
{
rc = Fcreate(atari_times[i].filename, 0);
if(rc > 0)
{
memset(message, 0, 300);
sprintf(message,
DATETIME_FORMAT,
YEAR(atari_times[i].date),
MONTH(atari_times[i].date),
DAY(atari_times[i].date),
HOUR(atari_times[i].time),
MINUTE(atari_times[i].time),
SECOND(atari_times[i].time),
atari_times[i].definition);
timestamp.date = atari_times[i].date;
timestamp.time = atari_times[i].time;
wRc = Fwrite(handle, strlen(message), message);
tRc = Fdatime(&timestamp, handle, 1);
cRc = Fclose(handle);
}
log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n",
atari_times[i].filename,
rc,
wRc,
cRc,
tRc);
}
}

View File

@@ -0,0 +1,60 @@
/****************************************************************************
Aaru Data Preservation Suite
-----------------------------------------------------------------------------
Author(s) : Natalia Portillo
--[ 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 warranty of
MERCHANTABILITY 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-2021 Natalia Portillo
*****************************************************************************/
#ifndef AARU_FSTESTER_SETTER_SRC_ATARI_TIME_H_
#define AARU_FSTESTER_SETTER_SRC_ATARI_TIME_H_
#define DATETIME_FORMAT "This file is dated %04d/%02d/%02d %02d:%02d:%02d for %s\n"
#define YEAR(t) ((((t)&0xFE00) >> 9) + 1980)
#define MONTH(t) (((t)&0x01E0) >> 5)
#define DAY(t) ((t)&0x001F)
#define HOUR(t) (((t)&0xF800) >> 11)
#define MINUTE(t) (((t)&0x07E0) >> 5)
#define SECOND(t) (((t)&0x001F) << 1)
typedef struct
{
char filename[9];
unsigned short date;
unsigned short time;
char definition[13];
} atari_time_tests_t;
#define KNOWN_ATARI_TIMES 12
#define MAX_TIME 0xBF7D
#define MAX_DATE 0xFF9F
#define Y1K_DATE 0x2621
#define Y2K_DATE 0x2821
#define MIN_DATE 0x0021
static const atari_time_tests_t atari_times[KNOWN_ATARI_TIMES] = {
{"MAXWTIME", MAX_DATE, MAX_TIME, "last written"},
{"MINWTIME", MIN_DATE, 0, "last written"},
{"Y19WTIME", Y1K_DATE, MAX_TIME, "last written"},
{"Y2KWTIME", Y2K_DATE, MAX_TIME, "last written"},
};
#endif // AARU_FSTESTER_SETTER_SRC_ATARI_TIME_H_