/usr/share/gnudatalanguage/lib/file_move.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 | ;+
; NAME: FILE_MOVE
;
; RESTRICTIONS: only for Unix (Unix, Linux and Mac OS X) systems
;
;-
; LICENCE:
; Copyright (C) 2015, NATCHKEBIA Ilia; 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_MOVE, source, dest, require_directory=require_directory, $
allow_same=allow_same, noexpand_path=noexpand_path, $
overwrite=overwrite, verbose=verbose, help=help, test=test ;, $
;
if (N_PARAMS() LT 2) then BEGIN
print, '% FILE_MOVE: 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]) 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_MOVE: 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_MOVE, 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'
return
endif
;
command='\cp '
option='-rf'
;
;
;
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_MOVE: require_directory, ', dest[ii], ' is not a valid directory '
return
endif
endfor
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
;test if file exists
if (FILE_TEST(escape_special_char(source[ii])) eq 0) then begin
print, '% FILE_MOVE: file, ', source[ii], ' does not exist! '
return
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) ;escape space characters
if(KEYWORD_SET(allow_same) and (snameesc eq dnameesc)) then return
;verify if it is possible to copy, without keyword overwrite
cp=1;
if ((Not KEYWORD_SET(overwrite))) then begin
nb=FILE_TEST(escape_special_char(destname))
if (nb eq 0) then cp=0 ; there is not same files in directory
endif
;copy
if((cp eq 0) or KEYWORD_SET(overwrite) and destIsDir eq 0) then begin
SPAWN, command+' '+snameesc+' '+dnameesc
SPAWN, 'rm '+option+' '+snameesc
endif else begin
if (destIsDir eq 1) then begin
SPAWN, command+' '+snameesc+' '+dnameesc+'/'
SPAWN, 'rm '+option+' '+snameesc
;NEEDS TO IMPLEMENT!!!!
;If DestPath specifies an existing directory and SourcePath also names a directory, FILE_MOVE checks for the existence of a subdirectory of DestPath with the same name as the source directory. If this subdirectory does not exist, the source directory is moved to the specified location. If the subdirectory does exist, an error is issued, and the rename operation is not carried out.
endif else begin
if(not KEYWORD_SET(quiet)) then print, '% FILE_MOVE: ', 'Destination file already exists. File: ', dest[ii]
endelse
endelse
endfor
;
;
if KEYWORD_SET(test) then STOP
;
end
|