The FILECOPY command
#1
When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?
Reply
#2
(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?

What does ERR say? This might give a clue.
„Let the machine do the dirty work.“
The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978
Reply
#3
(06-15-2025, 06:00 PM)Albert Richheimer Wrote:
(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?

What does ERR say? This might give a clue.
There is no ERR message. And thats whats suspicious. The command just doesn't work. Or does it write the new file elsewhere on the drive?

(06-15-2025, 06:21 PM)Tillmann Viefhaus Wrote:
(06-15-2025, 06:00 PM)Albert Richheimer Wrote:
(06-15-2025, 05:04 PM)Tillmann Viefhaus Wrote: When I write:

CHDR "D:\Test_with_Files"

A = "Original.exe"
B = "Original_Copy.exe"
Filecopy A, B

A is existing on the harddrive but File B is not created. Why is that?

What does ERR say? This might give a clue.
There is no ERR message. And thats whats suspicious. The command just doesn't work. Or does it write the new file elsewhere on the drive?
I found the error. I just had the wrong filename which was the one of the program I was working with. The file A used in FILECOPY must never contain the name or parts of the name of a programm which is just running.
Reply
#4
(06-15-2025, 06:21 PM)Tillmann Viefhaus Wrote: I found the error. I just had the wrong filename which was the one of the program I was working with. The file A used in FILECOPY must never contain the name or parts of the name of a programm which is just running.

No. The running program only has a write lock applied. I still can be read – what PB's filecopy is doing.

I just have tested it:

Code:
#compile exe
#dim all

function pbmain () as long
    local sFileA as string
    local sFileB as string
    sFileA = "test.exe"    ' This running program
    sFileB = "copy_of_test.exe"
    filecopy sFileA,sFileB
    if err then
       stderr str$(err)+": "+error$(err)
    end if
    if isfile(sFileB)=0 then
       stderr "Filecopy did not succeed."
    end if
end function

The filecopy is doing fine.
„Let the machine do the dirty work.“
The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978
Reply
#5
'Question is in PowerBASIC for Windows section, so changed Albert's code
'to PBWin from PBCC.
'
'I was curious if FileA is itself the running EXE containing FILECOPY.
'But that works fine also. (see #COMPILE line)
'
Code:
#compile exe "test.exe"
#dim all
'
function pbmain () as long
    local sFileA as string
    local sFileB as string
    sFileA = "test.exe"    ' This running program
    sFileB = "copy_of_test.exe"
    filecopy sFileA,sFileB
    if err then
      'stderr str$(err)+": "+error$(err)
      ? str$(err)+": "+error$(err)
    end if
    if isfile(sFileB)=0 then
      'stderr "Filecopy did not succeed."
      ? "Filecopy did not succeed."
    end if
    ? "done"
end function '
'that leaves CHDR "D:\Test_with_Files"
'1. is the program that is doing the FILECOPY in D:\Test_with_Files ?
'2. if FileA is not in D:\Test_with_Files it will not be found by FILECOPY.
'
'code in post 1 had no error checking and PB does not display "messages"
'unless asked.
'
'Cheers,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)