File: newest.sci

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (27 lines) | stat: -rw-r--r-- 675 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function k=newest(varargin)
// given to files names f1 and f2 newest returns 
// the index of the newest file 
// non-existant files are supposed to be the oldest ones
//!
// Copyright INRIA
  n=size(varargin)
  if n==1 then names=varargin(1),else names=varargin,end
  n=prod(size(names))
  dat=zeros(1,n)
  for k=1:prod(size(names))
    nk=names(k)
    if strindex(nk,['SCI/','SCI\','sci/','sci\'])==1 then
      nk=SCI+part(nk,4:length(nk))
    elseif strindex(nk,['~/','~\'])==1 then
      nk=home+part(nk,2:length(nk))
    end
    info=fileinfo(nk)
    if info==[] then 
      dat(k)=0
    else
      dat(k)=info(6)
    end
  end
  [dat,k]=sort(dat)
  k=k(1)
endfunction