Function readfile() doesn't read large files

Things you’d like to miss in the future...
Post Reply
waqu
Posts: 17
Joined: 04 Jan 2015 05:58
Location: Russia/Saint-Petersburg
Contact:

Function readfile() doesn't read large files

Post by waqu »

I use this code to copy files:

Code: Select all

 writefile("I:\Temp\file.avi",readfile("D:\Temp\file.avi","b"),,"b");
Files size over 100 MB copied incompletely, but only the first 100Mb.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Function readfile() don't read large file

Post by highend »

Iirc, the limit is by design.

Why are you trying to copy an .avi file by readfile / writefile?
One of my scripts helped you out? Please donate via Paypal

waqu
Posts: 17
Joined: 04 Jan 2015 05:58
Location: Russia/Saint-Petersburg
Contact:

Re: Function readfile() don't read large file

Post by waqu »

highend wrote:Iirc, the limit is by design.

Why are you trying to copy an .avi file by readfile / writefile?
I need to merge multiple files into one.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Function readfile() doesn't read large files

Post by highend »

Use the dos copy command instead (with run / runret):

Code: Select all

copy /b file1+file2+file3 targetFile
One of my scripts helped you out? Please donate via Paypal

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Function readfile() doesn't read large files

Post by PeterH »

You *could* also test for file size, and if too big, copy parts of the file in a loop.
(readfile() knows operands for numbytes and start)

But in general highends solution seems more straightforward :tup:
Win11 Pro 223H2 Gerrman

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Function readfile() doesn't read large files

Post by highend »

It's a kind of operation I wouldn't do with XY just because you block it while the script is running and assembling large video files is (on non ssds) a time consuming process so it's better to externalize it (at least if you don't want to use a XY instance only for this task).
One of my scripts helped you out? Please donate via Paypal

waqu
Posts: 17
Joined: 04 Jan 2015 05:58
Location: Russia/Saint-Petersburg
Contact:

Re: Function readfile() doesn't read large files

Post by waqu »

highend wrote:Use the dos copy command instead (with run / runret):

Code: Select all

copy /b file1+file2+file3 targetFile
I need after the merger split file of the same size.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Function readfile() doesn't read large files

Post by highend »

Then use PeterH's method or a command line splitting tool?

E.g.:
http://www.lawrencegoetz.com/programs/gfs101.zip

or
split from:
http://sourceforge.net/projects/unxutils/
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 60595
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Function readfile() doesn't read large files

Post by admin »

FYI, upcoming change log has a tip:

Code: Select all

    > SC readfile: This command will not read more than 100 MB at a time. To 
      read larger files use the "start" parameter and do it portion by portion.
      This information has been missing from the help so far. Will be added soon.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Function readfile() doesn't read large files

Post by SkyFrontier »

'start' method is obsolete/innacurate/inadequate since XY started distinguishing double-byte chars, isn't it?
(written completely by bad memory, as I stumbled on this often in the past)
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 60595
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Function readfile() doesn't read large files

Post by admin »

Not at all! In the case of double-byte chars "start" points to the character position. Easy and intuitive to use.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Function readfile() doesn't read large files

Post by SkyFrontier »

I recall I had problems because XY was auto-detecting and forcing readfile() to interpret sections as single or double chars, leading to said innacuracy... Can this be user driven?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 60595
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Function readfile() doesn't read large files

Post by admin »

Did some tests: no problems visible.

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Function readfile() doesn't read large files

Post by PeterH »

admin wrote:In the case of double-byte chars "start" points to the character position. Easy and intuitive to use.

Code: Select all

    > SC readfile: This command will not read more than 100 MB at a time. To
      read larger files use the "start" parameter and do it portion by portion.
      This information has been missing from the help so far. Will be added soon.
      Note that the "start" parameter points to the *character* position in case
      of text files (in double-byte encodings this is different from the byte
      position).
Docu (maybe old?) says:
numbytes: number of bytes to read
start: byte position to read from

OK: if numbytes and start are consistent, this "charcount" may be fine.

But note: if max 100MB may be read, numbytes (being chars!) *must* be sufficient smaller for multibyte charsets?
(Else it would be 100Mchars :biggrin: )
Win11 Pro 223H2 Gerrman

admin
Site Admin
Posts: 60595
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Function readfile() doesn't read large files

Post by admin »

Yes, Help needs and upgrade here...

Post Reply