static int del_entry(direntry_t *entry, MainParam_t *mp) { Arg_t *arg=(Arg_t *) mp->arg; if(got_signal) return ERROR_ONE; if(entry->entry == -3) { fprintf(stderr, "Cannot remove root directory\n"); return ERROR_ONE; } if (arg->verbose) { fprintf(stderr,"Removing "); fprintPwd(stderr, entry,0); fputc('\n', stderr); } if (entry->dir.attr & (ATTR_READONLY | ATTR_SYSTEM)) { char tmp[4*MAX_VNAMELEN+1]; wchar_to_native(entry->name,tmp,MAX_VNAMELEN); if (ask_confirmation("%s: \"%s\" is read only, erase anyway (y/n) ? ", progname, tmp)) return ERROR_ONE; } if (fatFreeWithDirentry(entry)) return ERROR_ONE; wipeEntry(entry); return GOT_ONE; }
/* Write a DOS name + extension into a legal unix-style name. */ char *unix_normalize (doscp_t *cp, char *ans, dos_name_t *dn) { char buffer[13]; wchar_t wbuffer[13]; char *a; int j; for (a=buffer,j=0; (j<8) && (dn->base[j] > ' '); ++j,++a) *a = dn->base[j]; if(dn->ext[0] > ' ') { *a++ = '.'; for (j=0; j<3 && dn->ext[j] > ' '; ++j,++a) *a = dn->ext[j]; } *a++ = '\0'; dos_to_wchar(cp, buffer, wbuffer, 13); wchar_to_native(wbuffer, ans, 13); return ans; }
static int list_file(direntry_t *entry, MainParam_t *mp) { unsigned long size; int i; int Case; int r; wchar_t ext[4]; wchar_t name[9]; doscp_t *cp; if(!all && (entry->dir.attr & 0x6)) return 0; if(concise && isSpecialW(entry->name)) return 0; r=enterDirectory(entry->Dir); if (r) return ERROR_ONE; if (wide) { if(filesInDir % 5) putchar(' '); else putchar('\n'); } if(IS_DIR(entry)){ size = 0; } else size = FILE_SIZE(&entry->dir); Case = entry->dir.Case; if(!(Case & (BASECASE | EXTCASE)) && mtools_ignore_short_case) Case |= BASECASE | EXTCASE; cp = GET_DOSCONVERT(entry->Dir); dos_to_wchar(cp, entry->dir.ext, ext, 3); if(Case & EXTCASE){ for(i=0; i<3;i++) ext[i] = towlower(ext[i]); } ext[3] = '\0'; dos_to_wchar(cp, entry->dir.name, name, 8); if(Case & BASECASE){ for(i=0; i<8;i++) name[i] = towlower(name[i]); } name[8]='\0'; if(wide){ if(IS_DIR(entry)) printf("[%s]%*s", global_shortname, (int) (15 - 2 - strlen(global_shortname)), ""); else printf("%-15s", global_shortname); } else if(!concise) { char tmpBasename[4*8+1]; char tmpExt[4*8+1]; wchar_to_native(name,tmpBasename,8); wchar_to_native(ext,tmpExt,3); if (name[0] == ' ') printf(" "); else if(mtools_dotted_dir) printf("%-12s ", global_shortname); else printf("%s %s ", tmpBasename, tmpExt); /* is a subdirectory */ if(IS_DIR(entry)) printf("<DIR> "); else printf(" %8ld", (long) size); printf(" "); print_date(&entry->dir); printf(" "); print_time(&entry->dir); if(debug) printf(" %s %d ", tmpBasename, START(&entry->dir)); if(*global_longname) printf(" %s", global_longname); printf("\n"); } else { char tmp[4*MAX_VNAMELEN+1]; wchar_to_native(entry->name,tmp,MAX_VNAMELEN); printf("%s/%s", dirPath, tmp); if(IS_DIR(entry)) putchar('/'); putchar('\n'); } filesOnDrive++; filesInDir++; bytesOnDrive += (mt_size_t) size; bytesInDir += (mt_size_t) size; return GOT_ONE; }