For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > September 2006 > Create Big size dummy File..









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Create Big size dummy File..
Hyo-Han Kim

2004-06-22, 2:42 pm

I am going to build a Application which is like FlashGet ..

I need to create big dummy file..

The size of dummy file could be over 500 MB.

How can I do this without My CPU time spending?


I Got some sample from freevbcode.com but it takes a lot of time to make
dummy file..

I need API calls, I guess.

TIA


Veign

2004-06-22, 2:42 pm

I don't think you are going to get away from the time thing too much. To
create the file bytes have to be written to disk, which takes time...

--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
--

"Hyo-Han Kim" <blueless@spmg.co.kr> wrote in message
news:e1A5r5%23VEHA.3988@tk2msftngp13.phx.gbl...
> I am going to build a Application which is like FlashGet ..
>
> I need to create big dummy file..
>
> The size of dummy file could be over 500 MB.
>
> How can I do this without My CPU time spending?
>
>
> I Got some sample from freevbcode.com but it takes a lot of time to make
> dummy file..
>
> I need API calls, I guess.
>
> TIA
>
>



Hyo-Han Kim

2004-06-22, 2:42 pm

Thanks for reply.

But I see Flashget create big dummy file (over 60MB) in a few seconds..


Event VB takes long time to create big dummy file , Some API could reduce
the time, I guess..



"Veign" <NOSPAMinveign@veign.com> wrote in message
news:%23LkJvU$VEHA.4024@TK2MSFTNGP09.phx.gbl...
> I don't think you are going to get away from the time thing too much. To
> create the file bytes have to be written to disk, which takes time...
>
> --
> Chris Hanscom
> MVP (Visual Basic)
> http://www.veign.com
> --
>
> "Hyo-Han Kim" <blueless@spmg.co.kr> wrote in message
> news:e1A5r5%23VEHA.3988@tk2msftngp13.phx.gbl...
>
>



Randy Birch

2004-06-22, 2:43 pm

This is instantaneous. The demo creates a 600 meg file. Watch for line
wraps.

Option Explicit

'-----------------------------------------------------------------------------------------
' Copyright ©1996-2004 VBnet, Randy Birch. All Rights Reserved Worldwide.
' Terms of use http://vbnet.mvps.org/terms/pages/terms.htm
'-----------------------------------------------------------------------------------------

Private Const GENERIC_READ As Long = &H80000000
Private Const GENERIC_WRITE As Long = &H40000000
Private Const INVALID_HANDLE_VALUE As Long = -1
Private Const OPEN_ALWAYS As Long = 4 'Create file if it does NOT
exist
Private Const FILE_BEGIN As Long = 0
Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80

Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal lpSecurityAttributes As Long, _
ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, _
ByVal hTemplateFile As Long) As Long

Private Declare Function SetFilePointer Lib "kernel32" _
(ByVal hFile As Long, _
ByVal lDistanceToMove As Long, _
lpDistanceToMoveHigh As Long, _
ByVal dwMoveMethod As Long) As Long

Private Declare Function SetEndOfFile Lib "kernel32" _
(ByVal hFile As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hFile As Long) As Long


Private Sub Command1_Click()

Dim hFile As Long
Dim sFile As String
Dim dbDesiredFileSize As Double
Dim dwFileSizeLow As Long
Dim dwFileSizeHigh As Long

sFile = "d:\hugefile1.dat"
dbDesiredFileSize = 600000000 '600 meg

hFile = CreateFile(sFile, _
GENERIC_READ Or GENERIC_WRITE, _
0&, _
ByVal 0&, _
OPEN_ALWAYS, _
FILE_ATTRIBUTE_NORMAL, _
0&)

If hFile <> INVALID_HANDLE_VALUE Then

Call cvtDouble2Longs(ByVal dbDesiredFileSize, _
dwFileSizeLow, _
dwFileSizeHigh)

If SetFilePointer(hFile, _
dwFileSizeLow, _
dwFileSizeHigh, _
FILE_BEGIN) > 0 Then


If SetEndOfFile(hFile) = 1 Then
Debug.Print "file created!"
End If 'SetEndOfFile

End If 'SetFilePointer

End If 'hFile

CloseHandle hFile

End Sub


Private Sub cvtDouble2Longs(ByVal dbl As Double, _
longLOW As Long, _
longHI As Long)

'convert a double -> 2 longs

'Note: a double is stored in 64 bits, of which
'52 bits are available for the mantissa. So
'don't use more than 5 hex digits for the
'upper DWord, or you'll loose precision.

Dim temp As Long
Dim dblTemp As Double
Dim IsNegative As Boolean

'use a constant to avoid the
'slow "2^31" below (2147483648)
Const G2 = 2# * &H40000000

If dbl < 0 Then
IsNegative = True
dblTemp# = -dbl - 1
Else: dblTemp# = dbl
End If

'(2 ^ 31)) = 2147483648
temp = Int(dblTemp# / G2)

'(2 ^ 31))
longLOW = dblTemp# - (temp * G2)

'(2 ^ 31)
If temp And 1 Then longLOW = longLOW Or -G2

longHI = Int(temp / 2)

If IsNegative Then
longLOW = Not longLOW
longHI = Not longHI
End If

End Sub





--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


"Hyo-Han Kim" <blueless@spmg.co.kr> wrote in message
news:O$I$A9$VEHA.1380@TK2MSFTNGP12.phx.gbl...
: Thanks for reply.
:
: But I see Flashget create big dummy file (over 60MB) in a few seconds..
:
:
: Event VB takes long time to create big dummy file , Some API could reduce
: the time, I guess..
:
:
:
: "Veign" <NOSPAMinveign@veign.com> wrote in message
: news:%23LkJvU$VEHA.4024@TK2MSFTNGP09.phx.gbl...
: > I don't think you are going to get away from the time thing too much.
To
: > create the file bytes have to be written to disk, which takes time...
: >
: > --
: > Chris Hanscom
: > MVP (Visual Basic)
: > http://www.veign.com
: > --
: >
: > "Hyo-Han Kim" <blueless@spmg.co.kr> wrote in message
: > news:e1A5r5%23VEHA.3988@tk2msftngp13.phx.gbl...
: > > I am going to build a Application which is like FlashGet ..
: > >
: > > I need to create big dummy file..
: > >
: > > The size of dummy file could be over 500 MB.
: > >
: > > How can I do this without My CPU time spending?
: > >
: > >
: > > I Got some sample from freevbcode.com but it takes a lot of time to
make
: > > dummy file..
: > >
: > > I need API calls, I guess.
: > >
: > > TIA
: > >
: > >
: >
: >
:
:

Hyo-Han Kim

2004-06-22, 2:43 pm

Great!!!

Wonderful job...

Thanks Randy..

I appreciate of it..



"Randy Birch" <rgb_removethis@mvps.org> wrote in message
news:%23hcdDvAWEHA.1144@TK2MSFTNGP10.phx.gbl...
> This is instantaneous. The demo creates a 600 meg file. Watch for line
> wraps.
>
> Option Explicit
>
>

'---------------------------------------------------------------------------
--------------
> ' Copyright ©1996-2004 VBnet, Randy Birch. All Rights Reserved Worldwide.
> ' Terms of use http://vbnet.mvps.org/terms/pages/terms.htm
>

'---------------------------------------------------------------------------
--------------
>
> Private Const GENERIC_READ As Long = &H80000000
> Private Const GENERIC_WRITE As Long = &H40000000
> Private Const INVALID_HANDLE_VALUE As Long = -1
> Private Const OPEN_ALWAYS As Long = 4 'Create file if it does NOT
> exist
> Private Const FILE_BEGIN As Long = 0
> Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80
>
> Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
> (ByVal lpFileName As String, _
> ByVal dwDesiredAccess As Long, _
> ByVal dwShareMode As Long, _
> ByVal lpSecurityAttributes As Long, _
> ByVal dwCreationDisposition As Long, _
> ByVal dwFlagsAndAttributes As Long, _
> ByVal hTemplateFile As Long) As Long
>
> Private Declare Function SetFilePointer Lib "kernel32" _
> (ByVal hFile As Long, _
> ByVal lDistanceToMove As Long, _
> lpDistanceToMoveHigh As Long, _
> ByVal dwMoveMethod As Long) As Long
>
> Private Declare Function SetEndOfFile Lib "kernel32" _
> (ByVal hFile As Long) As Long
>
> Private Declare Function CloseHandle Lib "kernel32" _
> (ByVal hFile As Long) As Long
>
>
> Private Sub Command1_Click()
>
> Dim hFile As Long
> Dim sFile As String
> Dim dbDesiredFileSize As Double
> Dim dwFileSizeLow As Long
> Dim dwFileSizeHigh As Long
>
> sFile = "d:\hugefile1.dat"
> dbDesiredFileSize = 600000000 '600 meg
>
> hFile = CreateFile(sFile, _
> GENERIC_READ Or GENERIC_WRITE, _
> 0&, _
> ByVal 0&, _
> OPEN_ALWAYS, _
> FILE_ATTRIBUTE_NORMAL, _
> 0&)
>
> If hFile <> INVALID_HANDLE_VALUE Then
>
> Call cvtDouble2Longs(ByVal dbDesiredFileSize, _
> dwFileSizeLow, _
> dwFileSizeHigh)
>
> If SetFilePointer(hFile, _
> dwFileSizeLow, _
> dwFileSizeHigh, _
> FILE_BEGIN) > 0 Then
>
>
> If SetEndOfFile(hFile) = 1 Then
> Debug.Print "file created!"
> End If 'SetEndOfFile
>
> End If 'SetFilePointer
>
> End If 'hFile
>
> CloseHandle hFile
>
> End Sub
>
>
> Private Sub cvtDouble2Longs(ByVal dbl As Double, _
> longLOW As Long, _
> longHI As Long)
>
> 'convert a double -> 2 longs
>
> 'Note: a double is stored in 64 bits, of which
> '52 bits are available for the mantissa. So
> 'don't use more than 5 hex digits for the
> 'upper DWord, or you'll loose precision.
>
> Dim temp As Long
> Dim dblTemp As Double
> Dim IsNegative As Boolean
>
> 'use a constant to avoid the
> 'slow "2^31" below (2147483648)
> Const G2 = 2# * &H40000000
>
> If dbl < 0 Then
> IsNegative = True
> dblTemp# = -dbl - 1
> Else: dblTemp# = dbl
> End If
>
> '(2 ^ 31)) = 2147483648
> temp = Int(dblTemp# / G2)
>
> '(2 ^ 31))
> longLOW = dblTemp# - (temp * G2)
>
> '(2 ^ 31)
> If temp And 1 Then longLOW = longLOW Or -G2
>
> longHI = Int(temp / 2)
>
> If IsNegative Then
> longLOW = Not longLOW
> longHI = Not longHI
> End If
>
> End Sub
>
>
>
>
>
> --
>
> Randy Birch
> MVP Visual Basic
> http://vbnet.mvps.org/
> Please respond only to the newsgroups so all can benefit.
>
>
> "Hyo-Han Kim" <blueless@spmg.co.kr> wrote in message
> news:O$I$A9$VEHA.1380@TK2MSFTNGP12.phx.gbl...
> : Thanks for reply.
> :
> : But I see Flashget create big dummy file (over 60MB) in a few seconds..
> :
> :
> : Event VB takes long time to create big dummy file , Some API could

reduce
> : the time, I guess..
> :
> :
> :
> : "Veign" <NOSPAMinveign@veign.com> wrote in message
> : news:%23LkJvU$VEHA.4024@TK2MSFTNGP09.phx.gbl...
> : > I don't think you are going to get away from the time thing too much.
> To
> : > create the file bytes have to be written to disk, which takes time...
> : >
> : > --
> : > Chris Hanscom
> : > MVP (Visual Basic)
> : > http://www.veign.com
> : > --
> : >
> : > "Hyo-Han Kim" <blueless@spmg.co.kr> wrote in message
> : > news:e1A5r5%23VEHA.3988@tk2msftngp13.phx.gbl...
> : > > I am going to build a Application which is like FlashGet ..
> : > >
> : > > I need to create big dummy file..
> : > >
> : > > The size of dummy file could be over 500 MB.
> : > >
> : > > How can I do this without My CPU time spending?
> : > >
> : > >
> : > > I Got some sample from freevbcode.com but it takes a lot of time to
> make
> : > > dummy file..
> : > >
> : > > I need API calls, I guess.
> : > >
> : > > TIA
> : > >
> : > >
> : >
> : >
> :
> :
>



J French

2004-06-22, 2:43 pm

On Mon, 21 Jun 2004 21:02:33 -0400, "Veign" <NOSPAMinveign@veign.com>
wrote:

>I don't think you are going to get away from the time thing too much. To
>create the file bytes have to be written to disk, which takes time...


Actually this is not true

Both Random and Binary access allow you to write data far beyond the
end of a file.

The stuff before is whatever garbage was on the disk.


Bob Butler

2004-06-22, 2:43 pm

"J French" <erewhon@nowhere.com> wrote in message
news:40d7d371.87498815@news.btclick.com
<cut>
> The stuff before is whatever garbage was on the disk.


The stuff before should all be nulls

--
Reply to the group so all can participate
VB.Net... just say "No"

Gale Green

2004-06-22, 2:43 pm

On Tue, 22 Jun 2004 06:26:48 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

> "J French" <erewhon@nowhere.com> wrote in message
> news:40d7d371.87498815@news.btclick.com
> <cut>
>
> The stuff before should all be nulls


I just did the following and it created a 20 Mb file, full of junk,
instantaneously. No nulls, just junk.

Gale.
=======================
Private Sub Command1_Click()
Dim MyFile As Integer
Dim Char As String
Char = Chr$(0)
MyFile = FreeFile
Open "C:\GGtemp.dat" For Binary As #MyFile
S #MyFile, 20000000
Put #MyFile, , Char
Close #MyFile
End Sub

Duane Bozarth

2004-06-22, 2:43 pm

Bob Butler wrote:
>
> "J French" <erewhon@nowhere.com> wrote in message
> news:40d7d371.87498815@news.btclick.com
> <cut>
>
> The stuff before should all be nulls


Why--what makes you think/say that? If it were to write all nulls (or
anything, for that matter) it would take the full time to write to disk
rather than simply creating the links and whatever data (if any) in the
actual i/o list.
Bob Butler

2004-06-22, 2:43 pm

"Gale Green" <gale@databeat.fsnet.co.uk> wrote in message
news:4pggd01dv65hmpeagqhp5cu3kbt76rrer5@
4ax.com
> On Tue, 22 Jun 2004 06:26:48 -0700, "Bob Butler"
> <tiredofit@nospam.com> wrote:
>
>
> I just did the following and it created a 20 Mb file, full of junk,
> instantaneously. No nulls, just junk.


What OS?

--
Reply to the group so all can participate
VB.Net... just say "No"

Bob Butler

2004-06-22, 2:43 pm

"Duane Bozarth" <dp_bozarth@swko.dot.net> wrote in message
news:40D844E3.327682D4@swko.dot.net
> Bob Butler wrote:
>
> Why--what makes you think/say that? If it were to write all nulls (or
> anything, for that matter) it would take the full time to write to
> disk rather than simply creating the links and whatever data (if any)
> in the actual i/o list.


I didn't say it wrote anything... it should be a very sparse file and
attempts to read anything in the unwritten area would not actually read
anything off disk; a block of nulls would be returned. Nothing gets written
until you fill in data and at that point the nulls would be written as
blocks are allocated.

It may be that Win9x or some other version of the OS is not doing it that
way; if so I'm surprised because it's a major security hole if y9ou are
getting data that was written before.

--
Reply to the group so all can participate
VB.Net... just say "No"

Gale Green

2004-06-22, 2:43 pm

On Tue, 22 Jun 2004 07:59:56 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

> "Gale Green" <gale@databeat.fsnet.co.uk> wrote in message
> news:4pggd01dv65hmpeagqhp5cu3kbt76rrer5@
4ax.com
>
> What OS?


Win 98 and Win 98 SE.

Bob Butler

2004-06-22, 2:43 pm

"Gale Green" <gale@databeat.fsnet.co.uk> wrote in message
news:bmigd010tvfiv7jo1vgipug4det9cnt2pa@
4ax.com
<cut>
> Win 98 and Win 98 SE.


Hmmm... maybe they do it differently then; Win2K definitely does not
allocate the space and the file looks like it is null-filled.

--
Reply to the group so all can participate
VB.Net... just say "No"

Gale Green

2004-06-22, 2:43 pm

On Tue, 22 Jun 2004 08:09:46 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

> "Gale Green" <gale@databeat.fsnet.co.uk> wrote in message
> news:bmigd010tvfiv7jo1vgipug4det9cnt2pa@
4ax.com
> <cut>
[color=darkred]
>
> Hmmm... maybe they do it differently then; Win2K definitely does not
> allocate the space and the file looks like it is null-filled.


Well, I was just about to suggest that Win 9x is probably using DOS
services for disc access but my discs are FAT32 so I'm not so sure.

Gale.

Duane Bozarth

2004-06-22, 2:43 pm

Bob Butler wrote:
>
> "Duane Bozarth" <dp_bozarth@swko.dot.net> wrote in message
> news:40D844E3.327682D4@swko.dot.net
>
> I didn't say it wrote anything... it should be a very sparse file and
> attempts to read anything in the unwritten area would not actually read
> anything off disk; a block of nulls would be returned. Nothing gets written
> until you fill in data and at that point the nulls would be written as
> blocks are allocated.


Well, "the stuff before" sure sounded to me like stuff on disk...

> It may be that Win9x or some other version of the OS is not doing it that
> way; if so I'm surprised because it's a major security hole if y9ou are
> getting data that was written before.


I'm not sure--this old machine <is> W95, I'll have to try on another,
but it's what I would expect (again w/o the security issue) -- data not
written would be whatever left over from before w/o explicit
initialization. That's just the way 'puters always worked, at least in
the olden days.

I just did the following test...
Private Sub Form_Load()
Dim MyFile As Integer
Dim Char As String
Dim i As Long

Char = Chr$(0)
MyFile = FreeFile
Open "C:\GGtemp.dat" For Binary As #MyFile
S #MyFile, 20000000
Put #MyFile, , Char
S #MyFile, 1
For i = 1 To 10
Get #MyFile, , Char
Debug.Print Char, Asc(Char)
Next i
Close #MyFile
End Sub

Immediate window shows
¢ 162
 8
0
0
ÿ 255
ÿ 255
ÿ 255
ÿ 255
¼ 188
 24

Definitely not all nulls...
VB does explicit variable initialization for example, but other
languages such as Fortran don't necessarily so what you get for the
value of x in the following code snippet is whatever just happened to be
in memory...

program test
real :: x

write(*,*) x
end

Of course, the value for a real may well then throw an exception in the
i/o routine on the write statement as the resulting bit pattern may well
not be a conforming real number.

I
J French

2004-06-22, 2:43 pm

On Tue, 22 Jun 2004 08:09:46 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

>"Gale Green" <gale@databeat.fsnet.co.uk> wrote in message
> news:bmigd010tvfiv7jo1vgipug4det9cnt2pa@
4ax.com
><cut>
>
>Hmmm... maybe they do it differently then; Win2K definitely does not
>allocate the space and the file looks like it is null-filled.
>


Is that on an NTFS file system ?

If so, I would not be surprized if it were null filled

However I /would/ expect FileLen to report the right value
- to VB
- and also a simple Dir at command prompt 'level'

AFAIK the OP simply wanted to create a big file
- he did not specify that he wanted 'disk eating'
- or what he wanted in it

He then got the misguided idea that using the APIs would help.
- something a few of us pointed out .. is tit-headed

If he would like to come back and specify /exactly/ what he really
wants, then ... the chances are he will get his answer.


Bob Butler

2004-06-22, 2:43 pm

"Duane Bozarth" <dp_bozarth@swko.dot.net> wrote in message
news:40D85FA1.527CFC3A@swko.dot.net
<cut>
> I'm not sure--this old machine <is> W95, I'll have to try on another,
> but it's what I would expect (again w/o the security issue) -- data
> not written would be whatever left over from before w/o explicit
> initialization. That's just the way 'puters always worked, at least
> in the olden days.


I guess it's just been too long since I worked on Win9x systems or with
FAT/FAT32 file systems. I knew they weren't secure, just didn't remember
them being *that* bad. NTFS under Win2K doesn't do that.

J French

2004-06-22, 10:41 pm

On Tue, 22 Jun 2004 10:01:41 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

>"Duane Bozarth" <dp_bozarth@swko.dot.net> wrote in message
>news:40D85FA1.527CFC3A@swko.dot.net
><cut>
>
>I guess it's just been too long since I worked on Win9x systems or with
>FAT/FAT32 file systems. I knew they weren't secure, just didn't remember
>them being *that* bad. NTFS under Win2K doesn't do that.
>


NTFS - AKA HPFS rather changed the rules

FAT used physical mapping

(Not IMO a bad idea)
NickHK

2004-06-24, 12:47 am

I get the same results (all nulls) on NTFS and FAT32 disks with W2K, so does
that make it an OS issue rather than disk format ?

NickHK

"J French" <erewhon@nowhere.com> wrote in message
news:40d887bd.30812343@news.btclick.com...
> On Tue, 22 Jun 2004 10:01:41 -0700, "Bob Butler"
> <tiredofit@nospam.com> wrote:
>
>
> NTFS - AKA HPFS rather changed the rules
>
> FAT used physical mapping
>
> (Not IMO a bad idea)



J French

2004-06-24, 12:47 am

On Wed, 23 Jun 2004 14:23:03 +0800, "NickHK" <TungCheWah@Invalid.com>
wrote:

>I get the same results (all nulls) on NTFS and FAT32 disks with W2K, so does
>that make it an OS issue rather than disk format ?


I am very surprized that you get all nulls under FAT32

Although I can guess how it is done, probably that historical second
copy of the FAT coming into play at last

.... there is a possibility that your FAT32 drive was 'clean'
Bob O`Bob

2004-06-24, 12:47 am

J French wrote:
>
> On Wed, 23 Jun 2004 14:23:03 +0800, "NickHK" <TungCheWah@Invalid.com>
> wrote:
>
>
> I am very surprized that you get all nulls under FAT32
>
> Although I can guess how it is done, probably that historical second
> copy of the FAT coming into play at last
>
> ... there is a possibility that your FAT32 drive was 'clean'



There's an additional possibility that something on the system is "cleaning"
unallocated diskspace. Way, way back when I was a defense contractor we had
TSRs which did exactly that. Sort of an anti-trashcan.



Bob
NickHK

2004-06-24, 12:47 am

J,
Filled the disk completely, deleted and still get all Nulls on a FAT32 disk.
Using Duane's code above, increasing the the file size to 2 GB takes
appreciably longer, so the system must be doing something - writing Nulls ?

NickHK

"J French" <erewhon@nowhere.com> wrote in message
news:40d969ee.88726762@news.btclick.com...
> On Wed, 23 Jun 2004 14:23:03 +0800, "NickHK" <TungCheWah@Invalid.com>
> wrote:
>
does[color=darkred]
>
> I am very surprized that you get all nulls under FAT32
>
> Although I can guess how it is done, probably that historical second
> copy of the FAT coming into play at last
>
> ... there is a possibility that your FAT32 drive was 'clean'



J French

2004-06-24, 6:36 pm

On Thu, 24 Jun 2004 11:20:39 +0800, "NickHK" <TungCheWah@Invalid.com>
wrote:

>J,
>Filled the disk completely, deleted and still get all Nulls on a FAT32 disk.
>Using Duane's code above, increasing the the file size to 2 GB takes
>appreciably longer, so the system must be doing something - writing Nulls ?
>


How interesting
- by 'appreciably' do you think it is long enough to be really writing
nulls ?

A 2Gb file would involve a bit more work on the FAT
- quite a lot of sectors to write
NickHK

2004-06-24, 6:36 pm

J,
Possibly 100 times that for Duane's initial 20Meg file.

NickHK

"J French" <erewhon@nowhere.com> wrote in message
news:40da8bf3.4362552@news.btclick.com...
> On Thu, 24 Jun 2004 11:20:39 +0800, "NickHK" <TungCheWah@Invalid.com>
> wrote:
>
disk.[color=darkred]
?[color=darkred]
>
> How interesting
> - by 'appreciably' do you think it is long enough to be really writing
> nulls ?
>
> A 2Gb file would involve a bit more work on the FAT
> - quite a lot of sectors to write



J French

2004-06-24, 6:36 pm

On Thu, 24 Jun 2004 16:53:42 +0800, "NickHK" <TungCheWah@Invalid.com>
wrote:

>J,
>Possibly 100 times that for Duane's initial 20Meg file.


It would be 100 times - as it is doing 100 times the work
- on the FAT alone

Out of interest, and only if you have enough time and disk space,
could you /copy/ the large file and see whether that takes the same
time as creating it
- that is not a totally accurate test, but if copy takes significantly
longer than creation, we can be fairly sure that it is not physically
writing nulls to disk.

NickHK

2004-06-24, 6:36 pm

J,
~4 minutes for a copy as opposed to ~90 seconds for a create.

NickHK

"J French" <erewhon@nowhere.com> wrote in message
news:40da9c34.8524506@news.btclick.com...
> On Thu, 24 Jun 2004 16:53:42 +0800, "NickHK" <TungCheWah@Invalid.com>
> wrote:
>
>
> It would be 100 times - as it is doing 100 times the work
> - on the FAT alone
>
> Out of interest, and only if you have enough time and disk space,
> could you /copy/ the large file and see whether that takes the same
> time as creating it
> - that is not a totally accurate test, but if copy takes significantly
> longer than creation, we can be fairly sure that it is not physically
> writing nulls to disk.
>



Tony Proctor

2004-06-24, 6:36 pm

In principle, sing to a very high file address (i.e. beyond the EOF) and
writing more data there should leave behind an expanse of random data from
the disk - I've certainly used some UNIX systems in the past that have
exhibited this, and very interesting it was to read through it too.

However, I'm wondering if the system file manager is having an influence
here. I know that it uses memory-mapped sections to implement its caching.
Uninitialised pages would then be created as 'demand zero', with the result
that when they're flushed, NULLs would be written to the output file. This
also explains why 'creation' is so much quicker than 'copying': Demand-zero
pages are very cheap to create, whilst paging-in all the content of a
previous file is comparatively expensive.

Tony Proctor

"NickHK" <TungCheWah@Invalid.com> wrote in message
news:e#ORakdWEHA.3284@TK2MSFTNGP12.phx.gbl...
> J,
> ~4 minutes for a copy as opposed to ~90 seconds for a create.
>
> NickHK
>
> "J French" <erewhon@nowhere.com> wrote in message
> news:40da9c34.8524506@news.btclick.com...
>
>



J French

2004-06-24, 6:37 pm

On Thu, 24 Jun 2004 19:03:57 +0800, "NickHK" <TungCheWah@Invalid.com>
wrote:

>J,
>~4 minutes for a copy as opposed to ~90 seconds for a create.
>

Thanks,

This needs investigation
kenaso

2006-09-29, 5:24 am

quote:
Originally posted by Hyo-Han Kim
I am going to build a Application which is like FlashGet ..

I need to create big dummy file..

The size of dummy file could be over 500 MB.

How can I do this without My CPU time spending?


I Got some sample from freevbcode.com but it takes a lot of time to make
dummy file..

I need API calls, I guess.

TIA



Try this:

' Create a file filled with Null values (ASCII decimal 0)
' Max size = 1GB
dblFileSize = 1073741824#
hFile = FreeFile
Open strPath & strName For Binary Access Write As #hFile
Put #hFile, dblFileSize, 0
Close #hFile

Hope this helps.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com