[fpc-pascal] File Enumeration speed
I am enumerating thru large numbers of files on my disk, and find I cant come close with findfirst / findnext to matching the speed of cmd line apps available in linux :eg ls / du I have a fairly tight file search function, and dont see how to gain more speed Would anybody know what the limiting factors would be ? does the operating system keep an index somewhere ? Thanks - SteveG ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] File Enumeration speed
On 28/07/12 19:58, Michael Van Canneyt wrote: On Sat, 28 Jul 2012, SteveG wrote: I am enumerating thru large numbers of files on my disk, and find I cant come close with findfirst / findnext to matching the speed of cmd line apps available in linux :eg ls / du A regular ls only does a getdents() call. FindFirst/FindNext does a getdents, but then additionally, per file in the result, a stat() call. I have a fairly tight file search function, and dont see how to gain more speed Would anybody know what the limiting factors would be ? The number of calls to stat() to get extended file information. I suspect that if you do a ls -l, it will be as slow as findfirst/findnext, because it does then 3 calls per file: from strace ls -l /etc I get: lstat("/etc/odbc.ini", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 lgetxattr("/etc/odbc.ini", "security.selinux", 0x14de920, 255) = -1 ENODATA (No data available) getxattr("/etc/odbc.ini", "system.posix_acl_access", 0x0, 0) = -1 EOPNOTSUPP (Operation not supported) If you want speedier operation, and have enough file information with the name, you can simply do a getdents(). does the operating system keep an index somewhere ? Normally not (at least other than the regular disc cache). Thanks Michael - I will do some study (ie find out what getdents() does) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FP Vector graphics library
On Wednesday 27 May 2009 04:49:12 Felipe Monteiro de Carvalho wrote: > Hello, > > I and another worker have developed a vector graphics library for Free > Pascal and I am thinking about making it modifyed-LGPL and adding to > the lazarus-ccr repository, like fpspreadsheet. So I was wondering, > anyone interrested in it? > > At the moment it supports only reading PDF and only writing GCode for > a CNC machine I am developing and also only lines and polylines (I > will be adding curves in the next months), but the main structure is > done and it is extensible for more formats and more geometrical > figures and it's properties. > > Here is the kind of code that you can write with it: > > Vec := TvVectorialDocument.Create; > try > Vec.ReadFromFile(dialogoAbrir.FileName, vfPDF); > Vec.WriteToStrings(memoCodigo.Lines, vfGCodeAvisoCNCPrototipoV5); > finally > Vec.Free; > end; > > Just 1 command to read a PDF, then the information is in the class and > just another command to save the output to a file, or a TStrings or a > TStream. > > Formats are added by adding units to the uses clause, so only > necessary code is linked. Upon initialization they add themselves to a > list of formats in the fpvectorial unit. > > bye, Count me as interested as well :) - I also have a CNC machine, and looking to be able to use pdf/svg from pascal - Well done ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] New wiki, ftp and mailing list server planned
And is there a way to use the German site in English? ;) +1 :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Redirecting input to a child process
On 08/05/11 05:38, Anton Shepelev wrote: Hello all, I have been experimenting with redirection of stan- dard I/O of child processes using FreePascal 2.4.2 on Windows. I have succeeded in capturing standard input and standard output, but failed to feed my own data to the child's standard input. The child process doesn't seem to receive any input at all, staying blocked forever. At first I thought it was a problem with my usage of WinApi, so I rewrote my program using the TProcess class... just to get the same result. The program feeds 'Anton' to the more.com program and captures part of its output: Program StrRedir; uses Classes, Process, Sysutils; const MaxByte = 255; type TStrBuf = packed record {As a way to read buffers into strings} case Boolean of true: ( size: Byte; buf: array[0..MaxByte] of Char; ); false:( txt: ShortString; ); end; var MoreProcess: TProcess; readCount: integer; strBuf: TStrBuf; begin MoreProcess := TProcess.Create(nil); MoreProcess.CommandLine := 'C:\WINDOWS\system32\cmd.exe /C more'; MoreProcess.Options := [poUsePipes]; MoreProcess.Execute; strBuf.txt := 'Anton'; MoreProcess.Input.Write(strBuf.buf, strBuf.size); MoreProcess.CloseInput(); writeLn('Waiting...');//This never ends while MoreProcess.Running do begin Sleep(50); end; writeLn('Wait finished.'); Sleep(100); strBuf.size := MoreProcess.Output.Read(strBuf.buf, 255); writeLn(strBuf.txt); end. Could you please help me to make it work? Thanks in advance, Anton Anton - I have attached an extract from some working code (hopefully I didnt remove anything necessary) It may help you move on a bit further SteveG Process.Execute // capture all proc output (if required) - watch for proc ending quickly, but data still waiting while ( Process.Running ) // cycle whilst process active OR( (poUsePipes IN Process.Options) AND (Process.Output.NumBytesAvailable > 0) ) // OR finished already, still data waiting do begin Sleep(1); if Terminated then break; // no pipes - not past here as causes exceptions to read process pipes if not enabled if NOT (poUsePipes IN Process.Options) then continue; // read output BytesAvailable := Process.Output.NumBytesAvailable; if BytesAvailable > 0 then begin SetLength(str1, BytesAvailable); Process.OutPut.Read(str1[1], BytesAvailable); StdOutStore += str1; end; // read errors BytesAvailable := Process.Stderr.NumBytesAvailable; if BytesAvailable > 0 then begin SetLength(str1, BytesAvailable); Process.Stderr.Read(str1[1], BytesAvailable); StdErrStore += str1; end; // send input if UsrSendMsg > '' then begin Process.Input.Write(UsrSendMsg[1], Length(UsrSendMsg)); UsrSendMsg := ''; end; end; ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Redirecting input to a child process
On 08/05/11 17:30, Anton Shepelev wrote: SteveG: Anton - I have attached an extract from some work- ing code (hopefully I didnt remove anything neces- sary) It may help you move on a bit further I turned your piece of code into a complete program, but it didn't work either. In fact, there is not much difference between your program and mine, except that in generality. But I am creating a process with redirected standard handles (poUsePipes) and am sending a tiny five-byte input to it, and expecitng a tiny output, so there's no need in the loop and in the various checks that your program has. Also, your program does not call CloseInput(), which makes me wonder how the process can ever end, because that way it is not going to get a EOF or error 109 ("Pipe has been ended") on its standard input. What OS is the code you sent me working on? This is working on Linux and WinXP I cut what I was hoping was just the relevant code from the unit, so it is missing a bit :) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Compiler Building
Please excuse this if in the wrong list (if so, pls advise correct list) I have a full CVS of latest FPC (1.9.6) running on WinXP and have been trying to rebuild the compiler as per http://www.stack.nl/~marcov/buildfaq.pdf, Following the instructions for 'make cycle' (or any others) gives the error Entering directory 'C:/fpc/rtl/win32' __missing_command_MKDIRPROG -p ../../rtl/units/i386-win32 process_begin: CreateProcess((null), __missing_command_MKDIRPROG -p ../../rtl/units/i386-win32, ...) failed. make (e=2): The system cannot find the file specified. Could somebody please advise on where I am going wrong? Thanks ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Suspending app
perhaps create a thread for your file checking code, and Sleep(xx) regularly to release the processor ? Darius Blaszijk wrote: Hi, I have an app that checks several files continuously and when the fileage has changed the app performs some instructions. I have put the checks in a loop. The drawback is that the processor is now 100% loaded. I could use the FindFirstChangeNotification API on windows. But is there a crossplatform alternative?? Darius Blaszijk ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Exceptions in Library
Would anybody be able to enlighten me on enabling exception trapping in Linux libraries ? As far as I can tell, exceptions propagate through to the main app - (written with Lazarus in this case). I would like to trap them directly within the library. Pointers, clues, links, examples (heck, even full source) really appreciated :) Thanks - SteveG ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Exceptions in Library
On 30/03/15 16:46, leledumbo wrote: As far as I can tell, exceptions propagate through to the main app - (written with Lazarus in this case). I would like to trap them directly within the library. // excp.pas library excp; {$mode objfpc} uses sysutils; procedure p; begin try raise exception.create('an exception') except on e: exception do writeln(e.message); end; end; exports p; end. // test.pas procedure p; external 'excp'; begin p end. run with: $ LD_LIBRARY_PATH=. ./test you should get: an exception tested on ManjaroLinux 64-bit. Tested this, and you are correct - it captures it correctly After further testing - It would seem to capture some but not others ? (contrived example - I know not to directly call a control within a library) this doesnt seem to be trapped - drops thru to main app try Str1 := TControl(0).Name; except on e: exception do writeln(e.message); end; Would this suggest a different signal attachment is necessary ? Thanks ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Possible bug in Numeric test
Not sure if this is considered a bug or not :) I have found this function returns TRUE if passed 'E1/E2/etc' I am guessing it is seeing the 'E' as exponent function IsNum( const sSrc :string ) :boolean; var Code :integer; Num :real = 0; begin Num := Num; Val(sSrc, Num, Code); Exit( Code = 0 ); end; Thanks - SteveG ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Possible bug in Numeric test
Drat, that was a bad assumption of mine - sorry I meant it fails for any of E1 or E2 entries so any entry beginning with E and then a following number eg: IsNum('E1'); Sorry for the poor example On 25/02/16 03:54, Vojtěch Čihák wrote: I tried your function in FPC 3.0.0 in mode ObjFPC and it returns False for string 'E1/E2/etc'. V. ______ > Od: steveg > Komu: "FPC-Pascal users discussions" > Datum: 24.02.2016 00:57 > Předmět: [fpc-pascal] Possible bug in Numeric test > Not sure if this is considered a bug or not :) I have found this function returns TRUE if passed 'E1/E2/etc' I am guessing it is seeing the 'E' as exponent function IsNum( const sSrc :string ) :boolean; var Code :integer; Num :real = 0; begin Num := Num; Val(sSrc, Num, Code); Exit( Code = 0 ); end; Thanks - SteveG ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal