pro quick_sirius, dir_in, nocopy=nocopy
;
;+
;NAME:
;	quick_sirius
;PURPSOSE:
;	To check the data that has already been copied from SIRIUS, and
;	copy all new that that has arrived since then (using GET_SIRIUS)
;INPUT:
;	none required
;OPTIONAL INPUT:
;	nocopy	- If present, just print status information, do not
;		  start the copy from SIRIUS.
;OUTPUT:
;	st_tim	- Start time structure with .time and .day fields
;	en_tim	- End time structure with .time and .day fields
;HISTORY:
;	Written 14-Nov-91 by M.Morrison
;-
;
qdebug = 0
;
cur_tim = make_str('{dummy, time: long(0), day: fix(0)}')
st_tim = cur_tim
en_tim = cur_tim	;define the structure types
;
cur_tarr = timstr2ex(!stime)
ex2int, cur_tarr, tt, dd & en_tim.time=tt & en_tim.day = dd		;found ending time for extraction
;
dir_base = '/flare1_raw_tlm_mount/v1/'
iyr = cur_tarr(6)
imon = cur_tarr(5)
;
nmonth_back = 0
qdone = 0
while (not qdone) do begin
    dir_in = dir_base + string(iyr, imon, format='(2i2.2)')
    nfil = file_info(concat_dir(dir_in, '*'), finfo)
    if (qdebug) then print, nfil, ' in ', dir_in
    if (nfil ne 0) then begin
	i = nfil-1
	while ((not qdone) and (i ge 0)) do begin
	    if (qdebug) then print, i, ' = ', finfo(i).name, finfo(i).size
	    if (finfo(i).size gt 10000) then qdone = 1 else i=i-1
	end
    end
    ;
    if (not qdone) then begin
	nmonth_back = nmonth_back+1
	imon = imon - 1
	if (imon eq 0) then begin
	    imon = 12
	    iyr = iyr - 1
	end
    end
    ;
    if (nmonth_back gt 2) then begin
	print, 'Cannot find a reference file to determine the start time'
	print, 'QUICK_SIRIUS: Stopping'
	stop
    end
end
;
infil = finfo(i).name
nrec = finfo(i).size / 9216
rd_telem, infil, nrec-1, rec1, err, /reverse
ttim2ex, rec1, tarr
ex2int, tarr, tt, dd & st_tim.time=tt & st_tim.day = dd		;found starting time for extraction
del_hrs = int2secarr(en_tim, st_tim)/60/60
;
print, 'Looking at file: ', infil
print, '   record # ', strtrim(nrec-1,2), ' the following was determined.
print, '   '
print, 'Start time for requested transfer: ', fmt_tim(st_tim)
print, 'End time for requested transfer:   ', fmt_tim(en_tim)
print, 'Duration since last copy: ', del_hrs, ' hours'
;
if (not keyword_set(nocopy)) then begin		;I seem to use double negatives a lot
    get_sirius, st_tim, en_tim
end
;
end
