December 17, 2003 Re: [Help] Access Violation Error | ||||
---|---|---|---|---|
| ||||
Try compiling it with debug info (-g) and run it under the debugger and see where it is dying. "Andrew Edwards" <edwardsac@spamfreeusa.com> wrote in message news:brolif$nf3$1@digitaldaemon.com... > The program below crashes on line 70 with Access Violation error. I've spent > in excess of 48 hours trying to determine why but am at a complete lost. Your assistance in identifying the cause, any tip on improving the code is greatly appreciated. > > Andrew > > ================================================================ > // plmsinstall.d > // (c) Andrew Edwards 2003 > // Author makes no implied or written > > private import std.stream; > private import urllib; // decoupled Burton's urllib from DIG: now compiles > with DMD v0.76 > private import std.zip; > alias std.c.windows.windows.GetFileAttributesA getFileAttributes; > > void main(char [][] args) > { > char [] dirname = "pubs"; > char [] path = "c:\\" ~ dirname ~ "\\"; > char [] filename = "monitor.dat"; > char [] url = "file://c:/plmszip.exe"; > byte [] plmszip; > > chdir("c:\\"); > if(fileExist(dirname)) > { > char [][] directory = listdir(dirname); > foreach(char[] file; directory) > remove(path ~ file); > rmdir(dirname); > } > mkdir(dirname); > chdir(dirname); > write(filename, "YA:\\C:\\C:\\"); > stdout.writeLine("Please stand by: Downloading file from Internet!"); > download(url, plmszip); // download SFX file from url > stdout.writeLine("Download complete"); > stdout.writeLine("Performing installation..."); > extract(plmszip); // extract only required files from SFX > stdout.writeLine("Instalation complete!"); > } > > bit fileExist(char[] filename) > { > return (getFileAttributes(toStringz(filename)) != 0xFFFFFFFF); > } > > void download(char[] source, out byte[] target) > { > target = urllib.urlread(source); > } > > void extract(byte[] buffer) > { > std.zip.ZipArchive zipfile; > zipfile = new std.zip.ZipArchive(cast(void[])buffer); > > byte [] ibuffer; // to hold extracted file plmsfile.exe > > // Extract plmszipfile.exe > foreach(ArchiveMember file; zipfile.directory) > { > if(file.name != "PLMSFILE.EXE") > continue; > > std.zip.ZipArchive plmsfile; > ibuffer = cast(byte[])zipfile.expand(file); > plmsfile = new std.zip.ZipArchive(cast(void[])ibuffer); > > stdout.writeString("Now entering "); > stdout.writeLine(file.name); > foreach(ArchiveMember file; plmsfile.directory) > { > if(file.name == "INSTALLS.BAT") > continue; > std.zip.ZipArchive archive; > ibuffer = null; > stdout.writeLine("Program crashes here with"); // Test > ibuffer = cast(byte[])plmsfile.expand(file); > stdout.writeLine("Access Violation Error"); // Test > archive = new std.zip.ZipArchive(cast(void[])ibuffer); > > foreach(ArchiveMember member; archive.directory) > { > write(member.name, cast(byte[])archive.expand(file)); > } > delete archive; > } > } > } > > |
Copyright © 1999-2021 by the D Language Foundation