Rename a remote (PC) file
#34507
12 Aug 21 09:09 PM
|
Joined: Sep 2002
Posts: 5,471
Frank
OP
Member
|
OP
Member
Joined: Sep 2002
Posts: 5,471 |
Environment: ATE->Linux
I am trying to rename a file in the local PC/ATE station.
The documentation for xcall rename would lead one to believe it would handle this: "supports AMOS or native operating system filenames" tho i surmise this does not apply to ATE. Either way i get a STATUS=255 when attempting the following
xcall rename, "c:\dir\one.txt","c:\dir\two.txt",status.
Is there any other way to perform this function?
TIA
|
|
|
Re: Rename a remote (PC) file
[Re: Frank]
#34508
12 Aug 21 09:41 PM
|
Joined: Jun 2001
Posts: 11,794
Jack McGregor
Member
|
Member
Joined: Jun 2001
Posts: 11,794 |
You surmise correctly. But there is another way to do it, using AG_WINEXEC. (You have to read way down into the History notes to see the $MOVE macro, which is probably the best option here.)
|
|
|
Re: Rename a remote (PC) file
[Re: Frank]
#34509
13 Aug 21 07:44 AM
|
Joined: Sep 2003
Posts: 4,158
Steve - Caliq
Member
|
Member
Joined: Sep 2003
Posts: 4,158 |
If it helps I dug out an old function we used to do this (it could do with a bit of a tidy) but does the job. Copy & Move/Rename
!
!==============================================================================
!{Copy or move a file} ! [099]
!==============================================================================
FUNCTION FN'WINDOWS'COPY'MOVE'FILE(F'SRC'FILE AS S0,F'DST'FILE AS S0,F'FLAG AS F6) AS F6
! IN: Windows Source File
! IN: Windows Dest File
! IN: Flag 0=Copy, 1=Move
! OUT: Status: 13=OK , 0=Failed -1=Source not found. -2=Function/copy Error.
ON ERROR GOTO LOCAL'TRAP
++PRAGMA AUTO_EXTERN "TRUE"
MAP1 LOCAL'STATUS,F,6
MAP1 LOCAL'SIZE,F,6
MAP1 LOCAL'EXECUTE,S,0
XCALL STRIP,F'SRC'FILE
XCALL STRIP,F'DST'FILE
FN'WINDOWS'COPY'MOVE'FILE=0
XCALL EXISTL,F'SRC'FILE,LOCAL'SIZE
IF LOCAL'SIZE=0 THEN
FN'WINDOWS'COPY'MOVE'FILE=-1
EXITFUNCTION
ENDIF
XCALL EXISTL,F'DST'FILE,LOCAL'SIZE
IF INSTR(1,F'SRC'FILE," ")<>0 THEN F'SRC'FILE=CHR(34)+F'SRC'FILE+CHR(34)
IF INSTR(1,F'DST'FILE," ")<>0 THEN F'DST'FILE=CHR(34)+F'DST'FILE+CHR(34)
IF LOCAL'SIZE>0 THEN CALL FN'DELETE'LOCAL'FILE(F'DST'FILE)
IF F'FLAG=1 THEN
LOCAL'EXECUTE="$MOVE "+F'SRC'FILE+" "+F'DST'FILE+CHR(127)
ELSE
LOCAL'EXECUTE="$"+"COPY "+F'SRC'FILE+" "+F'DST'FILE+CHR(127)
ENDIF
PRINT TAB(-10,AG_WINEXEC);LOCAL'EXECUTE;
XCALL ACCEPN,LOCAL'STATUS
FN'WINDOWS'COPY'MOVE'FILE=LOCAL'STATUS
EXITFUNCTION
LOCAL'TRAP:
FN'WINDOWS'COPY'MOVE'FILE=-2
XCALL MESAG,"Windows Copy/Move Function Error "+CHR(13)+F'SRC'FILE+CHR(13)+"to"+CHR(13)+F'DST'FILE+&
CHR(13)+"One possible reason is the destination folder does not exist.",2
RESUME ENDFUNCTION
ENDFUNCTION
|
|
|
Re: Rename a remote (PC) file
[Re: Frank]
#34510
13 Aug 21 07:47 AM
|
Joined: Sep 2003
Posts: 4,158
Steve - Caliq
Member
|
Member
Joined: Sep 2003
Posts: 4,158 |
I see now this function also used XCALL EXISTL.SBX to see if the local windows side file exists.
!========================================================================
! EXISTL - Local File Lookup 17/01/06
!========================================================================
! Supported under ATE and Ashell Windows.
! ZTerm/dumb terminals etc return -1.
!
!Usage:
! XCALL EXISTL,filename,size
!
! Size returns: -1 - not support ZTerm Etc.
! 0 - not found
! >0 - found, and byte size.
!
!========================================================================
++PRAGMA SBX
++PRAGMA ERROR_IF_NOT_MAPPED "ON"
++include xcall.bsi
!PROBAS=X {Madics PROBAS will auto compile with /X if this line is here)
!
!--------------------------------------------------------------------
!{Maps}
!--------------------------------------------------------------------
MAP1 SBX'NAME,S,6
MAP1 PRGNAM,S,6
MAP1 MISC
MAP2 GUI'AVAIL,F,6
MAP2 ATE'USED,F,6
MAP2 NULL'PARAM,F,6
MAP2 LOCAL'USED,F,6
MAP1 PARMS
MAP2 X'FILE,S,510
MAP2 X'SIZE,F,6
MAP1 LOOKUP'LOCAL
MAP2 LOOKUP'LOCATION,S,1
MAP2 LOOKUP'FILE,S,510
MAP2 LOOKUP'UTIME,S,12
MAP2 LOOKUP'FMTIME,B,4
MAP2 LOOKUP'FCTIME,B,4
MAP2 LOOKUP'FMODE,B,2
MAP2 LOOKUP'BYTES,F
MAP2 LOOKUP'MOD'DATE,S,100
MAP2 LOOKUP'CREATE'DATE,S,100
!
!==============================================================================
!{Start here}
!==============================================================================
on error goto TRAP
XCALL NOECHO : FILEBASE 1 : SIGNIFICANCE 11
XCALL GETPRG,PRGNAM,SBX'NAME
XGETARGS X'FILE,X'SIZE
XCALL WINATE,GUI'AVAIL,ATE'USED,NULL'PARAM,LOCAL'USED
X'SIZE=0
IF GUI'AVAIL=0 THEN
X'SIZE=-1
ELSE
CALL CHECK'EXISTS
ENDIF
XPUTARG 2,X'SIZE
END
!
!==============================================================================
!{Does it exist?}
!==============================================================================
CHECK'EXISTS:
IF ATE'USED=1 THEN LOOKUP'LOCATION="R"
IF LOCAL'USED=1 THEN LOOKUP'LOCATION="L"
LOOKUP'FILE=X'FILE
XCALL MIAMEX,131,LOOKUP'LOCATION,LOOKUP'FILE,LOOKUP'BYTES,LOOKUP'FMTIME,LOOKUP'FCTIME,LOOKUP'FMODE
IF LOOKUP'BYTES=<0 THEN
X'SIZE=0
ELSE
X'SIZE=LOOKUP'BYTES
ENDIF
RETURN
!
!==============================================================================
!{Trap}
!==============================================================================
TRAP:
XCALL MESAG,SBX'NAME+".SBX ERROR: "+STR(ERR(0))+" ON FILE "+STR(ERR(2))+ &
", LINE "+STR(ERR(1)),2
END ! return to caller
|
|
|
Re: Rename a remote (PC) file
[Re: Frank]
#34511
13 Aug 21 01:12 PM
|
Joined: Sep 2002
Posts: 5,471
Frank
OP
Member
|
OP
Member
Joined: Sep 2002
Posts: 5,471 |
Thanks Chum!
|
|
|
|
|