mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-30 14:56:23 +00:00
utils: dos33: whitespace cleanup
This commit is contained in:
parent
7458087e2d
commit
a2a9d6ef52
@ -1080,23 +1080,28 @@ static int dos33_rename_file(int fd,int fts,char *new_name) {
|
|||||||
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
|
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
|
||||||
|
|
||||||
/* copy over filename */
|
/* copy over filename */
|
||||||
for(x=0;x<strlen(new_name);x++)
|
for(x=0;x<strlen(new_name);x++) {
|
||||||
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+
|
sector_buffer[CATALOG_FILE_LIST+
|
||||||
|
(catalog_file*CATALOG_ENTRY_SIZE)+
|
||||||
FILE_NAME+x]=new_name[x]^0x80;
|
FILE_NAME+x]=new_name[x]^0x80;
|
||||||
|
}
|
||||||
|
|
||||||
/* pad out the filename with spaces */
|
/* pad out the filename with spaces */
|
||||||
for(x=strlen(new_name);x<FILE_NAME_SIZE;x++)
|
for(x=strlen(new_name);x<FILE_NAME_SIZE;x++) {
|
||||||
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+
|
sector_buffer[CATALOG_FILE_LIST+
|
||||||
|
(catalog_file*CATALOG_ENTRY_SIZE)+
|
||||||
FILE_NAME+x]=' '^0x80;
|
FILE_NAME+x]=' '^0x80;
|
||||||
|
}
|
||||||
|
|
||||||
/* write back modified catalog sector */
|
/* write back modified catalog sector */
|
||||||
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
lseek(fd,DISK_OFFSET(catalog_track,catalog_sector),SEEK_SET);
|
||||||
result=write(fd,sector_buffer,BYTES_PER_SECTOR);
|
result=write(fd,sector_buffer,BYTES_PER_SECTOR);
|
||||||
|
|
||||||
if (result<0) fprintf(stderr,"Error on I/O\n");
|
if (result<0) {
|
||||||
|
fprintf(stderr,"Error on I/O\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* undelete a file. fts=entry/track/sector */
|
/* undelete a file. fts=entry/track/sector */
|
||||||
@ -1119,13 +1124,15 @@ static int dos33_undelete_file(int fd,int fts,char *new_name) {
|
|||||||
/* FIXME: should walk file to see if T/s valild */
|
/* FIXME: should walk file to see if T/s valild */
|
||||||
/* by setting the track value to FF which indicates deleted file */
|
/* by setting the track value to FF which indicates deleted file */
|
||||||
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)]=
|
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)]=
|
||||||
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+
|
sector_buffer[CATALOG_FILE_LIST+
|
||||||
|
(catalog_file*CATALOG_ENTRY_SIZE)+
|
||||||
FILE_NAME+29];
|
FILE_NAME+29];
|
||||||
|
|
||||||
/* restore file name if possible */
|
/* restore file name if possible */
|
||||||
|
|
||||||
replacement_char=0xa0;
|
replacement_char=0xa0;
|
||||||
if (strlen(new_name)>29) replacement_char=new_name[29]^0x80;
|
if (strlen(new_name)>29) {
|
||||||
|
replacement_char=new_name[29]^0x80;
|
||||||
|
}
|
||||||
|
|
||||||
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+
|
sector_buffer[CATALOG_FILE_LIST+(catalog_file*CATALOG_ENTRY_SIZE)+
|
||||||
FILE_NAME+29]=replacement_char;
|
FILE_NAME+29]=replacement_char;
|
||||||
@ -1137,7 +1144,6 @@ static int dos33_undelete_file(int fd,int fts,char *new_name) {
|
|||||||
if (result<0) fprintf(stderr,"Error on I/O\n");
|
if (result<0) fprintf(stderr,"Error on I/O\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1161,22 +1167,20 @@ static int dos33_delete_file(int fd,int fsl) {
|
|||||||
file_type=sector_buffer[CATALOG_FILE_LIST+
|
file_type=sector_buffer[CATALOG_FILE_LIST+
|
||||||
(catalog_entry*CATALOG_ENTRY_SIZE)
|
(catalog_entry*CATALOG_ENTRY_SIZE)
|
||||||
+FILE_TYPE];
|
+FILE_TYPE];
|
||||||
|
|
||||||
if (file_type&0x80) {
|
if (file_type&0x80) {
|
||||||
fprintf(stderr,"File is locked! Unlock before deleting!\n");
|
fprintf(stderr,"File is locked! Unlock before deleting!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* get pointer to t/s list */
|
/* get pointer to t/s list */
|
||||||
ts_track=sector_buffer[CATALOG_FILE_LIST+catalog_entry*CATALOG_ENTRY_SIZE+
|
ts_track=sector_buffer[CATALOG_FILE_LIST+
|
||||||
FILE_TS_LIST_T];
|
catalog_entry*CATALOG_ENTRY_SIZE+FILE_TS_LIST_T];
|
||||||
ts_sector=sector_buffer[CATALOG_FILE_LIST+catalog_entry*CATALOG_ENTRY_SIZE+
|
ts_sector=sector_buffer[CATALOG_FILE_LIST+
|
||||||
FILE_TS_LIST_S];
|
catalog_entry*CATALOG_ENTRY_SIZE+FILE_TS_LIST_S];
|
||||||
|
|
||||||
keep_deleting:
|
keep_deleting:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* load in the t/s list info */
|
/* load in the t/s list info */
|
||||||
lseek(fd,DISK_OFFSET(ts_track,ts_sector),SEEK_SET);
|
lseek(fd,DISK_OFFSET(ts_track,ts_sector),SEEK_SET);
|
||||||
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
|
result=read(fd,sector_buffer,BYTES_PER_SECTOR);
|
||||||
@ -1184,10 +1188,12 @@ keep_deleting:
|
|||||||
/* Free each sector listed by t/s list */
|
/* Free each sector listed by t/s list */
|
||||||
for(i=0;i<TSL_MAX_NUMBER;i++) {
|
for(i=0;i<TSL_MAX_NUMBER;i++) {
|
||||||
/* If t/s = 0/0 then no need to clear */
|
/* If t/s = 0/0 then no need to clear */
|
||||||
if ((sector_buffer[TSL_LIST+2*i]==0) && (sector_buffer[TSL_LIST+2*i+1]==0)) {
|
if ((sector_buffer[TSL_LIST+2*i]==0) &&
|
||||||
|
(sector_buffer[TSL_LIST+2*i+1]==0)) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dos33_free_sector(fd,sector_buffer[TSL_LIST+2*i],sector_buffer[TSL_LIST+2*i+1]);
|
dos33_free_sector(fd,sector_buffer[TSL_LIST+2*i],
|
||||||
|
sector_buffer[TSL_LIST+2*i+1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user