mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-06 13:34:32 +02:00
From Lucho: converted TM_ENCODE into a function. Various cleanups in fatfs.c
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@942 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
42c0af3aee
commit
de5bed6d28
@ -39,14 +39,6 @@ static BYTE *time_hRcsId =
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FAT Time notation in the form of hhhh hmmm mmmd dddd */
|
|
||||||
|
|
||||||
#define TM_HOUR(t) (((t)>>11)&0x1f)
|
|
||||||
#define TM_MIN(t) (((t)>>5)&0x3f)
|
|
||||||
#define TM_DEC(t) ((t)&0x1f)
|
|
||||||
|
|
||||||
#define TM_ENCODE(h,m,d) ((((h)&0x1f)<<11)|(((m)&0x3f)<<5)|((d)&0x1f))
|
|
||||||
|
|
||||||
typedef UWORD time;
|
typedef UWORD time;
|
||||||
|
|
||||||
struct dostime
|
struct dostime
|
||||||
|
@ -58,6 +58,12 @@ CLUSTER first_fat(f_node_ptr);
|
|||||||
COUNT map_cluster(f_node_ptr, COUNT);
|
COUNT map_cluster(f_node_ptr, COUNT);
|
||||||
STATIC VOID shrink_file(f_node_ptr fnp);
|
STATIC VOID shrink_file(f_node_ptr fnp);
|
||||||
|
|
||||||
|
/* FAT time notation in the form of hhhh hmmm mmmd dddd (d = double second) */
|
||||||
|
STATIC time time_encode(struct dostime *t)
|
||||||
|
{
|
||||||
|
return (t->hour << 11) | (t->minute << 5) | (t->second >> 1);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WITHFAT32
|
#ifdef WITHFAT32
|
||||||
CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry)
|
CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry)
|
||||||
{
|
{
|
||||||
@ -68,12 +74,8 @@ CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry)
|
|||||||
|
|
||||||
void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value)
|
void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value)
|
||||||
{
|
{
|
||||||
if (!ISFAT32(dpbp))
|
|
||||||
{
|
|
||||||
dentry->dir_start = (UWORD)value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dentry->dir_start = (UWORD)value;
|
dentry->dir_start = (UWORD)value;
|
||||||
|
if (ISFAT32(dpbp))
|
||||||
dentry->dir_start_high = (UWORD)(value >> 16);
|
dentry->dir_start_high = (UWORD)(value >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +126,7 @@ STATIC void init_direntry(struct dirent *dentry, unsigned attrib,
|
|||||||
dentry->dir_crtimems = dt.hundredth;
|
dentry->dir_crtimems = dt.hundredth;
|
||||||
if (dt.second & 1)
|
if (dt.second & 1)
|
||||||
dentry->dir_crtimems += 100;
|
dentry->dir_crtimems += 100;
|
||||||
dentry->dir_time = dentry->dir_crtime =
|
dentry->dir_time = dentry->dir_crtime = time_encode(&dt);
|
||||||
TM_ENCODE(dt.hour, dt.minute, dt.second >> 1);
|
|
||||||
dentry->dir_date = dentry->dir_crdate = dentry->dir_accdate = dos_getdate();
|
dentry->dir_date = dentry->dir_crdate = dentry->dir_accdate = dos_getdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,16 +259,9 @@ long dos_open(char *path, unsigned flags, unsigned attrib)
|
|||||||
|
|
||||||
BOOL fcmp_wild(const char * s1, const char * s2, unsigned n)
|
BOOL fcmp_wild(const char * s1, const char * s2, unsigned n)
|
||||||
{
|
{
|
||||||
while (n--)
|
for ( ; n--; ++s1, ++s2)
|
||||||
{
|
if (*s1 != '?' && *s1 != *s2)
|
||||||
if (*s1 == '?')
|
|
||||||
{
|
|
||||||
++s1, ++s2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (*s1++ != *s2++)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,7 +876,7 @@ time dos_gettime(void)
|
|||||||
/* First - get the system time set by either the user */
|
/* First - get the system time set by either the user */
|
||||||
/* on start-up or the CMOS clock */
|
/* on start-up or the CMOS clock */
|
||||||
DosGetTime(&dt);
|
DosGetTime(&dt);
|
||||||
return TM_ENCODE(dt.hour, dt.minute, dt.second >> 1);
|
return time_encode(&dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
@ -1183,8 +1177,7 @@ COUNT dos_mkdir(BYTE * dir)
|
|||||||
return DE_BLKINVLD;
|
return DE_BLKINVLD;
|
||||||
}
|
}
|
||||||
fmemset(bp->b_buffer, 0, BUFFERSIZE);
|
fmemset(bp->b_buffer, 0, BUFFERSIZE);
|
||||||
bp->b_flag |= BFR_DIRTY | BFR_VALID;
|
bp->b_flag |= BFR_DIRTY | BFR_VALID | BFR_UNCACHE; /* need not be cached */
|
||||||
bp->b_flag |= BFR_UNCACHE; /* need not be cached */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flush the drive buffers so that all info is written */
|
/* flush the drive buffers so that all info is written */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user