Changeset 268
- Timestamp:
- 11/17/02 15:32:42 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/Directory.java
r157 r268 3 3 * 4 4 * Copyright (C) 1998-2002 Peter Graves 5 * $Id: Directory.java,v 1. 5 2002-10-17 14:12:36piso Exp $5 * $Id: Directory.java,v 1.6 2002-11-17 15:32:42 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 57 57 private int numMarked = 0; 58 58 59 // The offset on the line where the filename starts.60 private int nameOffset = -1;61 62 59 private DirectoryHistory history = new DirectoryHistory(); 63 60 64 static privateRE nativeMoveToFilenameRegExp;65 static privateRE internalMoveToFilenameRegExp;61 private static RE nativeMoveToFilenameRegExp; 62 private static RE internalMoveToFilenameRegExp; 66 63 67 64 private long totalSize; … … 97 94 RESyntax syntax = new RESyntax(RESyntax.RE_SYNTAX_PERL5); 98 95 syntax.set(RESyntax.RE_CHAR_CLASSES); 99 nativeMoveToFilenameRegExp = new RE("[0-9]+" + s + monthAndDay + 100 s + timeOrYear + s, 0, syntax); 96 97 String normal = "[0-9]+" + s + monthAndDay + s + timeOrYear + s; 98 99 // --time-style=long-iso 100 // -rw-r--r-- 1 peter peter 147 2002-11-13 13:10 notes 101 // --time-style=iso 102 // -rw-r--r-- 1 peter peter 69016 11-16 18:29 Directory.java 103 // -rw-r--r-- 1 peter peter 13274 2001-09-08 thinbox.tar.gz 104 String iso = "[0-9]+" + s + "[0-9\\-]+" + s + "(" + HHMM + ")? *"; 105 106 nativeMoveToFilenameRegExp = 107 new RE("(" + normal + ")|(" + iso + ")", 0, syntax); 101 108 internalMoveToFilenameRegExp = new RE(":[0-5][0-9]" + s); 102 109 } 103 catch (REException e) {} 110 catch (REException e) { 111 Log.error(e); 112 } 104 113 } 105 114 … … 578 587 else if (sortBy == SORT_BY_SIZE) 579 588 flags = "-laS"; 589 String extraOptions = 590 getStringProperty(Property.LS_EXTRA_OPTIONS); 591 if (extraOptions != null) { 592 flags += " "; 593 flags += extraOptions; 594 Log.debug("Directory.loadInternal flags = " + flags); 595 } 580 596 BufferedReader reader = null; 581 597 if (getListing() != null) { … … 668 684 try { 669 685 addEntriesToBuffer(); 670 setNameOffset(); // We may have changed formats.671 686 if (totalSize != 0) { 687 int end; 688 if (usingNativeFormat) { 689 end = getFileSizeEndOffset(); 690 if (end <= 0) 691 end = 45; 692 } else { 693 int nameOffset = getNameOffset(); 694 end = nameOffset - 19; 695 if (end <= 0) 696 end = 13; 697 } 672 698 String s = String.valueOf(totalSize); 673 int end =674 usingNativeFormat ? nameOffset - 14 : nameOffset - 19;675 699 int begin = end - s.length(); 700 if (begin < 0) 701 begin = 0; 676 702 FastStringBuffer sb = new FastStringBuffer(80); 677 703 sb.append(Utilities.spaces(begin)); … … 1851 1877 { 1852 1878 if (line != null) { 1853 try { 1854 REMatch match; 1855 if (usingNativeFormat) 1856 match = nativeMoveToFilenameRegExp.getMatch(line.getText()); 1857 else 1858 match = internalMoveToFilenameRegExp.getMatch(line.getText()); 1859 if (match != null) 1860 return match.getEndIndex(); 1861 } 1862 catch (Exception e) { 1863 Log.error(e); 1864 } 1879 REMatch match; 1880 if (usingNativeFormat) 1881 match = nativeMoveToFilenameRegExp.getMatch(line.getText()); 1882 else 1883 match = internalMoveToFilenameRegExp.getMatch(line.getText()); 1884 if (match != null) 1885 return match.getEndIndex(); 1865 1886 } 1866 1887 return 0; 1867 1888 } 1868 1889 1869 private void setNameOffset() 1870 { 1871 nameOffset = 0; 1890 private int getNameOffset() 1891 { 1892 return getNameOffset(getFirstLine()); 1893 } 1894 1895 private int getFileSizeEndOffset() 1896 { 1872 1897 Line line = getFirstLine(); 1873 1898 if (line != null) { 1874 try {1875 1876 1877 match = nativeMoveToFilenameRegExp.getMatch(line.getText());1878 1879 match = internalMoveToFilenameRegExp.getMatch(line.getText());1880 if (match != null)1881 nameOffset = match.getEndIndex();1882 }1883 catch (Exception e) {1884 Log.error(e);1885 1886 }1899 final String text = line.getText(); 1900 REMatch match; 1901 if (usingNativeFormat) 1902 match = nativeMoveToFilenameRegExp.getMatch(text); 1903 else 1904 match = internalMoveToFilenameRegExp.getMatch(text); 1905 if (match != null) { 1906 int start = match.getStartIndex(); 1907 // The file size is followed by a single space. 1908 return text.indexOf(' ', start); 1909 } 1910 } 1911 return -1; // Error! 1887 1912 } 1888 1913
Note: See TracChangeset
for help on using the changeset viewer.