428
+ − 1 /* fast dired replacement routines for mswindows.
+ − 2 Copyright (C) 1998 Darryl Okahata
+ − 3 Portions Copyright (C) 1992, 1994 by Sebastian Kremer <sk@thp.uni-koeln.de>
+ − 4
+ − 5 This file is part of XEmacs.
+ − 6
+ − 7 XEmacs is free software; you can redistribute it and/or modify it
+ − 8 under the terms of the GNU General Public License as published by the
+ − 9 Free Software Foundation; either version 2, or (at your option) any
+ − 10 later version.
+ − 11
+ − 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ − 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ − 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ − 15 for more details.
+ − 16
+ − 17 You should have received a copy of the GNU General Public License
+ − 18 along with XEmacs; see the file COPYING. If not, write to
+ − 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ − 20 Boston, MA 02111-1307, USA. */
+ − 21
+ − 22 /* Synched up with: Not in FSF. */
+ − 23
+ − 24 /*
+ − 25 * Parts of this code (& comments) were taken from ls-lisp.el
+ − 26 * Author: Sebastian Kremer <sk@thp.uni-koeln.de>
+ − 27 */
+ − 28
+ − 29 /*
+ − 30 * insert-directory
+ − 31 * - must insert _exactly_one_line_ describing FILE if WILDCARD and
+ − 32 * FULL-DIRECTORY-P is nil.
+ − 33 * The single line of output must display FILE's name as it was
+ − 34 * given, namely, an absolute path name.
+ − 35 * - must insert exactly one line for each file if WILDCARD or
+ − 36 * FULL-DIRECTORY-P is t, plus one optional "total" line
+ − 37 * before the file lines, plus optional text after the file lines.
+ − 38 * Lines are delimited by "\n", so filenames containing "\n" are not
+ − 39 * allowed.
+ − 40 * File lines should display the basename.
+ − 41 * - must be consistent with
+ − 42 * - functions dired-move-to-filename, (these two define what a file line is)
+ − 43 * dired-move-to-end-of-filename,
+ − 44 * dired-between-files, (shortcut for (not (dired-move-to-filename)))
+ − 45 * dired-insert-headerline
+ − 46 * dired-after-subdir-garbage (defines what a "total" line is)
+ − 47 * - variable dired-subdir-regexp
+ − 48 */
+ − 49
+ − 50 /*
+ − 51 * Insert directory listing for FILE, formatted according to SWITCHES.
+ − 52 * Leaves point after the inserted text.
+ − 53 * SWITCHES may be a string of options, or a list of strings.
+ − 54 * Optional third arg WILDCARD means treat FILE as shell wildcard.
+ − 55 * Optional fourth arg FULL-DIRECTORY-P means file is a directory and
+ − 56 * switches do not contain `d', so that a full listing is expected.
+ − 57 *
+ − 58 * This works by running a directory listing program
+ − 59 * whose name is in the variable `insert-directory-program'.
+ − 60 * If WILDCARD, it also runs the shell specified by `shell-file-name'."
+ − 61 */
+ − 62
+ − 63 /*
+ − 64 * Set INDENT_LISTING to non-zero if the inserted text should be shifted
+ − 65 * over by two spaces.
+ − 66 */
+ − 67 #define INDENT_LISTING 0
+ − 68
+ − 69 #define ROUND_FILE_SIZES 4096
+ − 70
+ − 71
+ − 72 #include <config.h>
+ − 73 #include "lisp.h"
+ − 74
+ − 75 #include "buffer.h"
558
+ − 76 #include "nt.h"
428
+ − 77 #include "regex.h"
+ − 78
+ − 79 #include "sysdir.h"
+ − 80 #include "sysproc.h"
442
+ − 81 #include "sysfile.h"
558
+ − 82 #include "sysfloat.h"
428
+ − 83
+ − 84
+ − 85 static int mswindows_ls_sort_case_insensitive;
458
+ − 86 static Fixnum mswindows_ls_round_file_size;
428
+ − 87
+ − 88 Lisp_Object Qmswindows_insert_directory;
+ − 89
+ − 90 extern Lisp_Object Vmswindows_downcase_file_names; /* in device-msw.c */
+ − 91
558
+ − 92 enum mswindows_sortby
+ − 93 {
428
+ − 94 MSWINDOWS_SORT_BY_NAME,
+ − 95 MSWINDOWS_SORT_BY_NAME_NOCASE,
+ − 96 MSWINDOWS_SORT_BY_MOD_DATE,
+ − 97 MSWINDOWS_SORT_BY_SIZE
+ − 98 };
+ − 99
+ − 100
+ − 101 static enum mswindows_sortby mswindows_sort_method;
+ − 102 static int mswindows_reverse_sort;
+ − 103
+ − 104
+ − 105 #define CMPDWORDS(t1a, t1b, t2a, t2b) \
+ − 106 (((t1a) == (t2a)) ? (((t1b) == (t2b)) ? 0 : (((t1b) < (t2b)) ? -1 : 1)) \
+ − 107 : (((t1a) < (t2a)) ? -1 : 1))
+ − 108
+ − 109
+ − 110 static int
+ − 111 mswindows_ls_sort_fcn (const void *elem1, const void *elem2)
+ − 112 {
+ − 113 WIN32_FIND_DATA *e1, *e2;
+ − 114 int status;
+ − 115
+ − 116 e1 = *(WIN32_FIND_DATA **)elem1;
+ − 117 e2 = *(WIN32_FIND_DATA **)elem2;
+ − 118 switch (mswindows_sort_method)
+ − 119 {
+ − 120 case MSWINDOWS_SORT_BY_NAME:
+ − 121 status = strcmp(e1->cFileName, e2->cFileName);
+ − 122 break;
+ − 123 case MSWINDOWS_SORT_BY_NAME_NOCASE:
+ − 124 status = _stricmp(e1->cFileName, e2->cFileName);
+ − 125 break;
+ − 126 case MSWINDOWS_SORT_BY_MOD_DATE:
+ − 127 status = CMPDWORDS(e1->ftLastWriteTime.dwHighDateTime,
+ − 128 e1->ftLastWriteTime.dwLowDateTime,
+ − 129 e2->ftLastWriteTime.dwHighDateTime,
+ − 130 e2->ftLastWriteTime.dwLowDateTime);
+ − 131 break;
+ − 132 case MSWINDOWS_SORT_BY_SIZE:
+ − 133 status = CMPDWORDS(e1->nFileSizeHigh, e1->nFileSizeLow,
+ − 134 e2->nFileSizeHigh, e2->nFileSizeLow);
+ − 135 break;
+ − 136 default:
+ − 137 status = 0;
+ − 138 break;
+ − 139 }
+ − 140 if (mswindows_reverse_sort)
+ − 141 {
+ − 142 status = -status;
+ − 143 }
+ − 144 return (status);
+ − 145 }
+ − 146
+ − 147
+ − 148 static void
+ − 149 mswindows_sort_files (WIN32_FIND_DATA **files, int nfiles,
+ − 150 enum mswindows_sortby sort_by, int reverse)
+ − 151 {
+ − 152 mswindows_sort_method = sort_by;
+ − 153 mswindows_reverse_sort = reverse;
+ − 154 qsort(files, nfiles, sizeof(WIN32_FIND_DATA *), mswindows_ls_sort_fcn);
+ − 155 }
+ − 156
+ − 157
+ − 158 static WIN32_FIND_DATA *
+ − 159 mswindows_get_files (char *dirfile, int nowild, Lisp_Object pattern,
+ − 160 int hide_dot, int hide_system, int *nfiles)
+ − 161 {
+ − 162 WIN32_FIND_DATA *files;
+ − 163 int array_size;
+ − 164 struct re_pattern_buffer *bufp = NULL;
+ − 165 int findex, len;
+ − 166 char win32pattern[MAXNAMLEN+3];
+ − 167 HANDLE fh;
+ − 168
+ − 169 /*
+ − 170 * Much of the following code and comments were taken from dired.c.
+ − 171 * Yes, this is something of a waste, but we want speed, speed, SPEED.
+ − 172 */
+ − 173 files = NULL;
+ − 174 array_size = *nfiles = 0;
+ − 175 while (1)
+ − 176 {
+ − 177 if (!NILP(pattern))
+ − 178 {
+ − 179 /* PATTERN might be a flawed regular expression. Rather than
+ − 180 catching and signalling our own errors, we just call
+ − 181 compile_pattern to do the work for us. */
446
+ − 182 bufp = compile_pattern (pattern, 0, Qnil, 0, ERROR_ME);
428
+ − 183 }
+ − 184 /* Now *bufp is the compiled form of PATTERN; don't call anything
+ − 185 which might compile a new regexp until we're done with the loop! */
+ − 186
+ − 187 /* Initialize file info array */
+ − 188 array_size = 100; /* initial size */
+ − 189 files = xmalloc(array_size * sizeof (WIN32_FIND_DATA));
+ − 190
+ − 191 /* for Win32, we need to insure that the pathname ends with "\*". */
+ − 192 strcpy (win32pattern, dirfile);
+ − 193 if (!nowild)
+ − 194 {
+ − 195 len = strlen (win32pattern) - 1;
+ − 196 if (!IS_DIRECTORY_SEP (win32pattern[len]))
+ − 197 strcat (win32pattern, "\\");
+ − 198 strcat (win32pattern, "*");
+ − 199 }
+ − 200
+ − 201 /*
+ − 202 * Here, we use FindFirstFile()/FindNextFile() instead of opendir(),
442
+ − 203 * xemacs_stat(), & friends, because xemacs_stat() is VERY expensive in
+ − 204 * terms of time. Hence, we take the time to write complicated
+ − 205 * Win32-specific code, instead of simple Unix-style stuff.
428
+ − 206 */
+ − 207 findex = 0;
+ − 208 fh = INVALID_HANDLE_VALUE;
+ − 209
+ − 210 while (1)
+ − 211 {
+ − 212 int len;
+ − 213 char *filename;
+ − 214 int result;
+ − 215
+ − 216 if (fh == INVALID_HANDLE_VALUE)
+ − 217 {
+ − 218 fh = FindFirstFile(win32pattern, &files[findex]);
+ − 219 if (fh == INVALID_HANDLE_VALUE)
+ − 220 {
+ − 221 report_file_error ("Opening directory",
563
+ − 222 build_string (dirfile));
428
+ − 223 }
+ − 224 }
+ − 225 else
+ − 226 {
+ − 227 if (!FindNextFile(fh, &files[findex]))
+ − 228 {
+ − 229 if (GetLastError() == ERROR_NO_MORE_FILES)
+ − 230 {
+ − 231 break;
+ − 232 }
+ − 233 FindClose(fh);
+ − 234 report_file_error ("Reading directory",
563
+ − 235 build_string (dirfile));
428
+ − 236 }
+ − 237 }
+ − 238
+ − 239 filename = files[findex].cFileName;
+ − 240 if (!NILP(Vmswindows_downcase_file_names))
+ − 241 {
+ − 242 strlwr(filename);
+ − 243 }
+ − 244 len = strlen(filename);
+ − 245 result = (NILP(pattern)
+ − 246 || (0 <= re_search (bufp, filename,
+ − 247 len, 0, len, 0)));
+ − 248 if (result)
+ − 249 {
+ − 250 if ( ! (filename[0] == '.' &&
+ − 251 ((hide_system && (filename[1] == '\0' ||
+ − 252 (filename[1] == '.' &&
+ − 253 filename[2] == '\0'))) ||
+ − 254 hide_dot)))
+ − 255 {
+ − 256 if (++findex >= array_size)
+ − 257 {
+ − 258 array_size = findex * 2;
+ − 259 files = xrealloc(files,
+ − 260 array_size * sizeof(WIN32_FIND_DATA));
+ − 261 }
+ − 262 }
+ − 263 }
+ − 264 }
+ − 265 if (fh != INVALID_HANDLE_VALUE)
+ − 266 {
+ − 267 FindClose (fh);
+ − 268 }
+ − 269 *nfiles = findex;
+ − 270 break;
+ − 271 }
+ − 272 return (files);
+ − 273 }
+ − 274
+ − 275
+ − 276 static void
+ − 277 mswindows_format_file (WIN32_FIND_DATA *file, char *buf, int display_size,
+ − 278 int add_newline)
+ − 279 {
+ − 280 char *cptr;
+ − 281 int len;
+ − 282 Lisp_Object luser;
+ − 283 double file_size;
+ − 284
+ − 285 len = strlen(file->cFileName);
+ − 286 file_size =
+ − 287 file->nFileSizeHigh * (double)UINT_MAX + file->nFileSizeLow;
+ − 288 cptr = buf;
+ − 289 #if INDENT_LISTING
+ − 290 *cptr++ = ' ';
+ − 291 *cptr++ = ' ';
+ − 292 #endif
+ − 293 if (display_size)
+ − 294 {
+ − 295 sprintf(cptr, "%6d ", (int)((file_size + 1023.) / 1024.));
+ − 296 cptr += 7;
+ − 297 }
+ − 298 if (file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ − 299 {
+ − 300 *cptr++ = 'd';
+ − 301 } else {
+ − 302 *cptr++ = '-';
+ − 303 }
+ − 304 cptr[0] = cptr[3] = cptr[6] = 'r';
+ − 305 if (file->dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+ − 306 {
+ − 307 cptr[1] = cptr[4] = cptr[7] = '-';
+ − 308 } else {
+ − 309 cptr[1] = cptr[4] = cptr[7] = 'w';
+ − 310 }
+ − 311 if ((file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
+ − 312 (len > 4 &&
+ − 313 (_stricmp(&file->cFileName[len - 4], ".exe") == 0
+ − 314 || _stricmp(&file->cFileName[len - 4], ".com") == 0
+ − 315 || _stricmp(&file->cFileName[len - 4], ".bat") == 0
+ − 316 #if 0
+ − 317 || _stricmp(&file->cFileName[len - 4], ".pif") == 0
+ − 318 #endif
+ − 319 )))
+ − 320 {
+ − 321 cptr[2] = cptr[5] = cptr[8] = 'x';
+ − 322 } else {
+ − 323 cptr[2] = cptr[5] = cptr[8] = '-';
+ − 324 }
+ − 325 cptr += 9;
+ − 326 if (file->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ − 327 {
+ − 328 strcpy(cptr, " 2 ");
+ − 329 } else {
+ − 330 strcpy(cptr, " 1 ");
+ − 331 }
+ − 332 cptr += 5;
+ − 333 luser = Fuser_login_name(Qnil);
+ − 334 if (!STRINGP(luser))
+ − 335 {
+ − 336 sprintf(cptr, "%-9d", 0);
+ − 337 } else {
+ − 338 char *str;
+ − 339
+ − 340 str = XSTRING_DATA(luser);
+ − 341 sprintf(cptr, "%-8s ", str);
+ − 342 }
+ − 343 while (*cptr)
+ − 344 {
+ − 345 ++cptr;
+ − 346 }
+ − 347 sprintf(cptr, "%-8d ", getgid());
+ − 348 cptr += 9;
+ − 349 if (file_size > 99999999.0)
+ − 350 {
+ − 351 file_size = (file_size + 1023.0) / 1024.;
+ − 352 if (file_size > 999999.0)
+ − 353 {
+ − 354 sprintf(cptr, "%6.0fMB ", (file_size + 1023.0) / 1024.);
+ − 355 } else {
+ − 356 sprintf(cptr, "%6.0fKB ", file_size);
+ − 357 }
+ − 358 } else {
+ − 359 sprintf(cptr, "%8.0f ", file_size);
+ − 360 }
+ − 361 while (*cptr)
+ − 362 {
+ − 363 ++cptr;
+ − 364 }
+ − 365 {
+ − 366 time_t t, now;
+ − 367 char *ctimebuf;
+ − 368 extern char *sys_ctime(const time_t *t); /* in nt.c */
+ − 369
+ − 370 if (
+ − 371 #if 0
+ − 372 /*
+ − 373 * This doesn't work.
+ − 374 * This code should be correct ...
+ − 375 */
+ − 376 FileTimeToLocalFileTime(&file->ftLastWriteTime, &localtime) &&
+ − 377 ((t = convert_time(localtime)) != 0) &&
+ − 378 #else
+ − 379 /*
+ − 380 * But this code "works" ...
+ − 381 */
+ − 382 ((t = convert_time(file->ftLastWriteTime)) != 0) &&
+ − 383 #endif
+ − 384 ((ctimebuf = sys_ctime(&t)) != NULL))
+ − 385 {
+ − 386 memcpy(cptr, &ctimebuf[4], 7);
+ − 387 now = time(NULL);
+ − 388 if (now - t > (365. / 2.0) * 86400.)
+ − 389 {
+ − 390 /* more than 6 months */
+ − 391 cptr[7] = ' ';
+ − 392 memcpy(&cptr[8], &ctimebuf[20], 4);
+ − 393 } else {
+ − 394 /* less than 6 months */
+ − 395 memcpy(&cptr[7], &ctimebuf[11], 5);
+ − 396 }
+ − 397 cptr += 12;
+ − 398 *cptr++ = ' ';
+ − 399 }
+ − 400 }
+ − 401 if (add_newline)
+ − 402 {
+ − 403 sprintf(cptr, "%s\n", file->cFileName);
+ − 404 }
+ − 405 else
+ − 406 {
+ − 407 strcpy(cptr, file->cFileName);
+ − 408 }
+ − 409 }
+ − 410
+ − 411
+ − 412 DEFUN ("mswindows-insert-directory", Fmswindows_insert_directory, 2, 4, 0, /*
+ − 413 Insert directory listing for FILE, formatted according to SWITCHES.
+ − 414 Leaves point after the inserted text.
+ − 415 SWITCHES may be a string of options, or a list of strings.
+ − 416 Optional third arg WILDCARD means treat FILE as shell wildcard.
+ − 417 Optional fourth arg FULL-DIRECTORY-P means file is a directory and
+ − 418 switches do not contain `d', so that a full listing is expected.
+ − 419 */
+ − 420 (file, switches, wildcard, full_directory_p))
+ − 421 {
+ − 422 Lisp_Object result, handler, wildpat, fns, basename;
+ − 423 char *switchstr;
622
+ − 424 int nfiles, i;
428
+ − 425 int hide_system, hide_dot, reverse, display_size;
+ − 426 WIN32_FIND_DATA *files, **sorted_files;
+ − 427 enum mswindows_sortby sort_by;
+ − 428 char fmtbuf[MAXNAMLEN+100]; /* larger than necessary */
+ − 429 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+ − 430
+ − 431 result = Qnil;
+ − 432 wildpat = Qnil;
+ − 433 fns = Qnil;
+ − 434 basename = Qnil;
+ − 435 GCPRO5(result, file, wildpat, fns, basename);
+ − 436 sorted_files = NULL;
+ − 437 switchstr = NULL;
+ − 438 hide_system = 1;
+ − 439 hide_dot = 1;
+ − 440 display_size = 0;
+ − 441 reverse = 0;
+ − 442 sort_by = (mswindows_ls_sort_case_insensitive
+ − 443 ? MSWINDOWS_SORT_BY_NAME_NOCASE
+ − 444 : MSWINDOWS_SORT_BY_NAME);
+ − 445 nfiles = 0;
+ − 446 while (1)
+ − 447 {
+ − 448 handler = Ffind_file_name_handler (file, Qmswindows_insert_directory);
+ − 449 if (!NILP(handler))
+ − 450 {
+ − 451 result = call5(handler, Qmswindows_insert_directory, file, switches,
+ − 452 wildcard, full_directory_p);
+ − 453 break;
+ − 454 }
+ − 455 CHECK_STRING (file);
+ − 456 if (!NILP(switches))
+ − 457 {
+ − 458 char *cptr;
+ − 459
+ − 460 CHECK_STRING (switches);
+ − 461 switchstr = XSTRING_DATA(switches);
+ − 462 for (cptr = switchstr; *cptr; ++cptr)
+ − 463 {
+ − 464 switch (*cptr)
+ − 465 {
+ − 466 case 'A':
+ − 467 hide_dot = 0;
+ − 468 break;
+ − 469 case 'a':
+ − 470 hide_system = 0;
+ − 471 hide_dot = 0;
+ − 472 break;
+ − 473 case 'r':
+ − 474 reverse = 1;
+ − 475 break;
+ − 476 case 's':
+ − 477 display_size = 1;
+ − 478 break;
+ − 479 case 'S':
+ − 480 sort_by = MSWINDOWS_SORT_BY_SIZE;
+ − 481 break;
+ − 482 case 't':
+ − 483 sort_by = MSWINDOWS_SORT_BY_MOD_DATE;
+ − 484 break;
+ − 485 }
+ − 486 }
+ − 487 }
+ − 488
+ − 489 if (!NILP(wildcard))
+ − 490 {
+ − 491 Lisp_Object newfile;
+ − 492
622
+ − 493 file = Fdirectory_file_name (file);
428
+ − 494 basename = Ffile_name_nondirectory(file);
+ − 495 fns = intern("wildcard-to-regexp");
+ − 496 wildpat = call1(fns, basename);
+ − 497 newfile = Ffile_name_directory(file);
+ − 498 if (NILP(newfile))
+ − 499 {
+ − 500 /* Ffile_name_directory() can GC */
+ − 501 newfile = Ffile_name_directory(Fexpand_file_name(file, Qnil));
+ − 502 }
+ − 503 file = newfile;
+ − 504 }
+ − 505 if (!NILP(wildcard) || !NILP(full_directory_p))
+ − 506 {
+ − 507 CHECK_STRING(file);
+ − 508 if (!NILP(wildpat))
+ − 509 {
+ − 510 CHECK_STRING(wildpat);
+ − 511 }
+ − 512
+ − 513 files = mswindows_get_files(XSTRING_DATA(file), FALSE, wildpat,
+ − 514 hide_dot, hide_system, &nfiles);
+ − 515 if (files == NULL || nfiles == 0)
+ − 516 {
+ − 517 break;
+ − 518 }
+ − 519 }
+ − 520 else
+ − 521 {
+ − 522 files = mswindows_get_files(XSTRING_DATA(file), TRUE, wildpat,
+ − 523 hide_dot, hide_system, &nfiles);
+ − 524 }
+ − 525 if ((sorted_files = xmalloc(nfiles * sizeof(WIN32_FIND_DATA *)))
+ − 526 == NULL)
+ − 527 {
+ − 528 break;
+ − 529 }
+ − 530 for (i = 0; i < nfiles; ++i)
+ − 531 {
+ − 532 sorted_files[i] = &files[i];
+ − 533 }
+ − 534 if (nfiles > 1)
+ − 535 {
+ − 536 mswindows_sort_files(sorted_files, nfiles, sort_by, reverse);
+ − 537 }
+ − 538 if (!NILP(wildcard) || !NILP(full_directory_p))
+ − 539 {
+ − 540 /*
+ − 541 * By using doubles, we can handle files up to 2^53 bytes in
+ − 542 * size (IEEE doubles have 53 bits of resolution). However,
+ − 543 * as we divide by 1024 (or 2^10), the total size is
+ − 544 * accurate up to 2^(53+10) --> 2^63 bytes.
+ − 545 *
+ − 546 * Hopefully, we won't have to handle these file sizes anytime
+ − 547 * soon.
+ − 548 */
+ − 549 double total_size, file_size, block_size;
+ − 550
+ − 551 if ((block_size = mswindows_ls_round_file_size) <= 0)
+ − 552 {
+ − 553 block_size = 0;
+ − 554 }
+ − 555 total_size = 0;
+ − 556 for (i = 0; i < nfiles; ++i)
+ − 557 {
+ − 558 file_size =
+ − 559 sorted_files[i]->nFileSizeHigh * (double)UINT_MAX +
+ − 560 sorted_files[i]->nFileSizeLow;
+ − 561 if (block_size > 0)
+ − 562 {
+ − 563 /*
+ − 564 * Round file_size up to the next nearest block size.
+ − 565 */
+ − 566 file_size =
+ − 567 floor((file_size + block_size - 1) / block_size)
+ − 568 * block_size;
+ − 569 }
+ − 570 /* Here, we round to the nearest 1K */
+ − 571 total_size += floor((file_size + 512.) / 1024.);
+ − 572 }
+ − 573 sprintf(fmtbuf,
+ − 574 #if INDENT_LISTING
+ − 575 /* ANSI C compilers auto-concatenate adjacent strings */
+ − 576 " "
+ − 577 #endif
+ − 578 "total %.0f\n", total_size);
+ − 579 buffer_insert1(current_buffer, build_string(fmtbuf));
+ − 580 }
+ − 581 for (i = 0; i < nfiles; ++i)
+ − 582 {
+ − 583 mswindows_format_file(sorted_files[i], fmtbuf, display_size, TRUE);
+ − 584 buffer_insert1(current_buffer, build_string(fmtbuf));
+ − 585 }
+ − 586 break;
+ − 587 }
+ − 588 if (sorted_files)
+ − 589 {
+ − 590 xfree(sorted_files);
+ − 591 }
+ − 592 UNGCPRO;
+ − 593 return (result);
+ − 594 }
+ − 595
+ − 596
+ − 597
+ − 598 /************************************************************************/
+ − 599 /* initialization */
+ − 600 /************************************************************************/
+ − 601
+ − 602 void
+ − 603 syms_of_dired_mswindows (void)
+ − 604 {
563
+ − 605 DEFSYMBOL (Qmswindows_insert_directory);
428
+ − 606
+ − 607 DEFSUBR (Fmswindows_insert_directory);
+ − 608 }
+ − 609
+ − 610
+ − 611 void
+ − 612 vars_of_dired_mswindows (void)
+ − 613 {
+ − 614 DEFVAR_BOOL ("mswindows-ls-sort-case-insensitive", &mswindows_ls_sort_case_insensitive /*
+ − 615 *Non-nil means filenames are sorted in a case-insensitive fashion.
+ − 616 Nil means filenames are sorted in a case-sensitive fashion, just like Unix.
+ − 617 */ );
+ − 618 mswindows_ls_sort_case_insensitive = 1;
+ − 619
+ − 620 DEFVAR_INT ("mswindows-ls-round-file-size", &mswindows_ls_round_file_size /*
+ − 621 *If non-zero, file sizes are rounded in terms of this block size when
+ − 622 the file totals are being calculated. This is useful for getting a more
+ − 623 accurate estimate of allocated disk space. Note that this only affects
+ − 624 the total size calculation; the individual displayed file sizes are not
+ − 625 changed. This block size should also be a power of 2 (but this is not
+ − 626 enforced), as filesystem block (cluster) sizes are typically powers-of-2.
+ − 627 */ );
+ − 628 /*
+ − 629 * Here, we choose 4096 because it's the cluster size for both FAT32
+ − 630 * and NTFS (?). This is probably much too small for people using
+ − 631 * plain FAT, but, hopefully, plain FAT will go away someday.
+ − 632 *
+ − 633 * We should allow something like a alist here, to make the size
+ − 634 * dependent on the drive letter, etc..
+ − 635 */
+ − 636 mswindows_ls_round_file_size = 4096;
+ − 637 }