/usr/share/gnudatalanguage/lib/file_copy.pro is in libgnudatalanguage0 0.9.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | ;+
; NAME: FILE_COPY
;
; RESTRICTIONS: only for Unix (Unix, Linux and Mac OS X) systems
;
;-
; LICENCE:
; Copyright (C) 2010, Lea Noreskal; contact: Alain Coulais
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;-
; ---------------------------------
;
pro FILE_COPY, source, dest, require_directory=require_directory, $
allow_same=allow_same, noexpand_path=noexpand_path, recursive=recursive, $
overwrite=overwrite, quiet=quiet, verbose=verbose, help=help, test=test ;, $
;not ready : force=force, copy_named_pipe=copy_named_pipe, copy_symlink=copy_symlink
;
if (N_PARAMS() LT 2) then BEGIN
print, '% FILE_COPY: Incorrect number of arguments.'
return
endif
;
if (Not KEYWORD_SET(noexpand_path)) then begin
flist=''
for ii=0,N_ELEMENTS(source)-1 do begin
dir=FILE_SEARCH(FILE_DIRNAME(source[ii]),/fully)
res=FILE_SEARCH(dir, FILE_BASENAME(source[ii]), /fully)
for jj=0,N_ELEMENTS(res)-1 do begin
if(FILE_DIRNAME(res[jj], /MARK_DIRECTORY) eq dir) then flist=[flist, res[jj]] ;
;print, 'dir ', dir, ' res ', FILE_DIRNAME(res[jj])
endfor
endfor
if(N_ELEMENTS(flist) gt 1) then source=flist[1:*]; print, flist ;;
; ...
for ii=0,N_ELEMENTS(dest)-1 do begin
struct=FILE_INFO(dest[ii])
if(struct.exists) then dest[ii]=escape_special_char(struct.name)
endfor
;...
endif
; either dest has the same size as source or it is a directory
destIsDir=0 ; 0 if dest is an array, 1 if it is a directory
if ( N_ELEMENTS(source) ne N_ELEMENTS(dest)) then begin
if( (N_ELEMENTS(dest) gt 1) $
or (FILE_TEST(dest[0], /directory) eq 0) ) then begin
print, '% FILE_COPY: Arrays source and dest must have same size, or dest must be a directory'
return
endif
; N_elements(dest) = 1 and dest is a directory
destIsDir=1
endif
;
;
if KEYWORD_SET(help) then begin
print, 'FUNCTION FILE_DELETE, source, dest,'
print, ' allow_same=allow_same, noexpand_path=noexpand_path, recursive=recursive, $'
print, ' overwrite=overwrite, require_directory=require directory, quiet=quiet, verbose=verbose, help=help, test=test'
;print, ' UNIX-Only Keywords: [/COPY_NAMED_PIPE] [, /COPY_SYMLINK] [, /FORCE] '
return
endif
;
command='\cp '
option='-'
;if KEYWORD_SET(allow_same) then begin
; print, 'Sorry, Keyword allow_same is not available now.'
; return
;endif
;
if KEYWORD_SET(require_directory) then begin
; verify if dest contains only directories
for ii=0, N_ELEMENTS(dest)-1 do begin
if ( FILE_TEST(dest[ii], /directory) eq 0 ) then begin
print, '% FILE_COPY: require_directory, ', dest[ii], ' is not a valid directory '
return
endif
endfor
endif
;
if KEYWORD_SET(recursive) then begin
option=option+'r'
endif
;
;if KEYWORD_SET(noexpand_path) then begin
; print, 'Sorry, Keyword NOEXPAND_PATH is not available now.'
; return
;endif
;
;cp=0;
;if KEYWORD_SET(overwrite) then begin
;endif
;
if KEYWORD_SET(copy_named_pipe) then begin
print, 'Sorry, Keyword copy_named_pipe is not available now.'
return
endif
;
if KEYWORD_SET(copy_symlink) then begin
option=option+'d'
endif
;
if KEYWORD_SET(force) then begin
option=option+'f'
endif
;
;if KEYWORD_SET(quiet) then begin
; print, 'Sorry, Keyword quiet is not available now.'
; return
;endif
;
if KEYWORD_SET(verbose) then begin
option=option+'v'
endif
;
;
if (STRLEN(option) GT 1 ) then begin
command=command+option
;print, 'opt >', option, ' Comm : ', command
endif
;
for ii=0, N_ELEMENTS(source)-1 do begin
if not KEYWORD_SET(recursive) then begin
if (FILE_TEST(source[ii], /directory) eq 1 ) then begin
if (KEYWORD_SET(verbose) or not KEYWORD_SET(quiet)) then print, '% FILE_COPY: ', source[ii], ' is a directory, use option /recursive'
return
endif
endif
; escape special characters
snameesc=escape_special_char(source[ii])
destname=dest[0] ; dest is a directory
;
if(destIsDir eq 0) then destname=dest[ii] ; dest is an array with several destination
;
dnameesc=escape_special_char(destname)
;if(KEYWORD_SET(allow_same) and (snameesc eq dnameesc)) > ne rien faire
;verify if it is possible to copy, without keyword overwrite
cp=1;
if ((Not KEYWORD_SET(overwrite)) and FILE_TEST(destname,/directory)) then begin
;sname=get_filename(source[ii]) ;
sname=FILE_BASENAME(source[ii])
res = FILE_SEARCH(destname, sname, COUNT=nb)
;print ,'RES : ' , res, ' sname : ', sname
if (nb ne 0) then cp=0 ; there is not same files in directory
endif
;copy
if((cp eq 1) and (not KEYWORD_SET(allow_same) or (snameesc ne dnameesc))) then SPAWN, command+' '+snameesc+' '+dnameesc
if(cp eq 0 and (KEYWORD_SET(verbose) or not KEYWORD_SET(quiet))) then print, '% FILE_COPY: ', source[ii] ,' overwrite not allowed '
endfor
;
if KEYWORD_SET(test) then STOP
;
end
|