Sign in to follow this  
Followers 0
corz

disk full during FileWriteLine

10 posts in this topic

If I am writing to a log file and free space runs out during the operation, AutoIt just keeps on going. FileWriteLine(handle) carries on as if there were space to write when there is not, returning true, no @error, nothing. If I use FileFlush(handle) every hundreds lines or so, it also always returns true.

So how can I tell that the disk is full during the writing (aside from continually checking DriveSpaceFree())?

I'm missing something obvious, right?

;o) Cor


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'd go for the DriveSpaceFree route, doesn't seem like FileWriteLine was written taking into account the free space, even tho, it states:

"Failure if file not opened in writemode, file is read only, or file cannot otherwise be written to."

But the thing is that it starts writing, maybe it only fails if it can't start.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

That's just the thing; when the file is initially opened, there is plenty space. It is during the writing that space runs out.

This certainly quacks like a bug!

;o) Cor


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

Can we see the code to try to reproduce? maybe strip out what you don't want us to see..


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

You could use AdlibRegister and write a function that checks drive space and IF its too full, then exit.  I know you said you didnt want to do that, but Adlib would make it fairly simple.

Adlib will run the function however often you need.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

haha! thanks, but it's not my first rodeo!

If you really want some code to reproduce this error (bug), the simplest of routines will do it, something like..

; Drive M: has 44KB space left
$handle = FileOpen("M:\some.file", 2)

; This should produce a file about twice that length..
for $i = 1 to 9999
    $written = FileWriteLine($handle, StringFormat('%05d',$i))
    if not $written then ConsoleWrite("ERROR " & "->" & @error & @LF)
next
; you will not see an error message!

FileCLose($handle)
exit

I love AdLib, and use it a fair bit, but in this sort of scenario, it would probably be smarter to use mod() to check every "so often" lines.

At any rate, I already coded in a work-around as it's possible, in my app at least, to know roughly how big the file will be before even opening it, so I check then.

I just thought I must be missing something as FileWriteLine() keeps on going as if it were working fine when it clearly is not. Looks like a bug in AutoIt.

;o) Cor

Edited by corz

nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

What happens is, the entire logical programming paradigm falls apart!

I'm not about to start testing for @error after a function returns true "just in case" it actually didn't!

At any rate, when it comes to FileWriteLine(), there is no @error, no returning false, nada!

;o) Cor


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

If I were you I'd go here and post a bug report about this, I tested this on a thumb drive on my computer and it's not working as expected. When the drive is full, FileWriteLine keeps saying it has written the line, when it clearly hasn't and can't. I checked to make sure, and it's not even overwriting the last line of the file with new data.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Yeah, I'll do that. Cheers BrewManNH

;o) Cor


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0