Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-06

Dircleaner example application bug

20 messages · 12 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Howard Page-Clark

There is a minor bug in the very useful example application dircleaner. The unit dircleaner.pp around line 441 has

FileNameFits:=Pos(Ext,FWorkExt)0;

to check if the current file under consideration fits the specified file extension.

This test is too simple since it does not look for an exact match. Suppose FWorkExt contains 'PPU' and the current file extension is 'PP'.

The program will delete all the .pp files it finds, as well as all the .ppu ones. The test has to be stricter.

Howard

Reply by email

Mattias Gaertner
to Howard Page-Clark
Show quoted text 13 lines
There is a minor bug in the very useful example application dircleaner. The unit dircleaner.pp around line 441 has FileNameFits:=Pos(Ext,FWorkExt)0; to check if the current file under consideration fits the specified file extension. This test is too simple since it does not look for an exact match. Suppose FWorkExt contains 'PPU' and the current file extension is 'PP'. The program will delete all the .pp files it finds, as well as all the .ppu ones. The test has to be stricter.

I improved it. Please test.

Mattias

Reply by email

Howard Page-Clark
to Mattias Gaertner
Mattias Gaertner wrote 18 lines
On Mon, 07 Jun 2010 23:54:22 +0100 Howard Page-Clark wrote: > There is a minor bug in the very useful example application dircleaner. > The unit dircleaner.pp around line 441 has > > FileNameFits:=Pos(Ext,FWorkExt)0; > > to check if the current file under consideration fits the specified file > extension. > > This test is too simple since it does not look for an exact match. > Suppose FWorkExt contains 'PPU' and the current file extension is 'PP'. > > The program will delete all the .pp files it finds, as well as all the > .ppu ones. The test has to be stricter. I improved it. Please test.

Your improvement fixes that bug, thanks.
However I could not get the confdirs project to compile and run without errors on Windows 7 until I commented out

confdirs.lpr line 15 {$R manifest.res}

frmmain.pp line 870	writeln('Adding', Loc[i].Name);

Also the FileActions tabsheet of the main config pagecontrol does not work properly. New actions are not shown, or the app crashes if an 'invisible' (but selected) action is deleted. I see that frmmain.pp line 990 has this comment in the method ShowFileActionItem(LI: TListItem):

// Bug in control: the items list is cleared!!
// UpdateActionLocations(FLocations);

Is the source of this bug known, and if so is the bug in the bugtracker?

Howard

Reply by email

Mattias Gaertner
to Howard Page-Clark
Show quoted text 25 lines
On 08/6/10 8:10, Mattias Gaertner wrote: > On Mon, 07 Jun 2010 23:54:22 +0100 > Howard Page-Clark wrote: > >> There is a minor bug in the very useful example application dircleaner. >> The unit dircleaner.pp around line 441 has >> >> FileNameFits:=Pos(Ext,FWorkExt)0; >> >> to check if the current file under consideration fits the specified file >> extension. >> >> This test is too simple since it does not look for an exact match. >> Suppose FWorkExt contains 'PPU' and the current file extension is 'PP'. >> >> The program will delete all the .pp files it finds, as well as all the >> .ppu ones. The test has to be stricter. > > I improved it. Please test. Your improvement fixes that bug, thanks. However I could not get the confdirs project to compile and run without errors on Windows 7 until I commented out confdirs.lpr line 15 {$R manifest.res}

Fixed. Please test under windows7

frmmain.pp line 870 writeln('Adding', Loc[i].Name);

Fixed.

Show quoted text 9 lines
Also the FileActions tabsheet of the main config pagecontrol does not work properly. New actions are not shown, or the app crashes if an 'invisible' (but selected) action is deleted. I see that frmmain.pp line 990 has this comment in the method ShowFileActionItem(LI: TListItem): // Bug in control: the items list is cleared!! // UpdateActionLocations(FLocations); Is the source of this bug known, and if so is the bug in the bugtracker?

Please create a bug report.

Mattias

Reply by email

K. P.
to Mattias Gaertner

Hi all ~
is there an API of sorts for reading version info across all supported platforms? ThanksKP
_________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100610/2fbfbef3/attachment.html>

Reply by email

K. P.
to K. P.

Hi all ~
am in the process of converting one of our win32 delphi apps to lazarus/cross platform. Converting something trivial like
ShellExecute( 0, nil, PChar( url ), nil, nil, SW_SHOWDEFAULT ); How can I find the default browser (if any) on supported platforms? Thanks for any pointers,KP

_________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100610/9d6f230e/attachment.html>

Reply by email

zeljko
to K. P.: Hi all ~ am in the process of converting one of our win32 delphi apps to lazarus/cross…
K. P. wrote 5 lines
Hi all ~ am in the process of converting one of our win32 delphi apps to lazarus/cross platform. Converting something trivial like ShellExecute( 0, nil, PChar( url ), nil, nil, SW_SHOWDEFAULT ); How can I find the default browser (if any) on supported platforms?
LCLIntf unit:
function FindDefaultBrowser(out ABrowser, AParams: String): Boolean;
function OpenURL(AURL: String): Boolean;
function OpenDocument(APath: String): Boolean;

Reply by email

Unknown author
to Mattias Gaertner: On Thu, 10 Jun 2010 16:31:51 +0000 unit LCLIntf function OpenURL Mattias

Mattias Gaertner wrote on 06/10/2010 12:42:58
PM:

Show quoted text 20 lines
06/10/2010 12:43 PM On Thu, 10 Jun 2010 16:31:51 +0000 "K. P." wrote: > > > Hi all ~ > am in the process of converting one of our win32 delphi apps to lazarus/cross platform. > Converting something trivial like > ShellExecute( 0, nil, PChar( url ), nil, nil, SW_SHOWDEFAULT ); > How can I find the default browser (if any) on supported platforms? unit LCLIntf function OpenURL Mattias

Only on 0.9.30+ IIRC. If you have an earlier version I believe you have to jump thru the hoops as documented in the wiki article(s). -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100610/a7308ab1/attachment.html>

Reply by email

Howard Page-Clark
to Mattias Gaertner: On Thu, 10 Jun 2010 14:45:34 +0100 Fixed. Please test under windows7 Fixed. Please create…
Mattias Gaertner wrote 30 lines
On Thu, 10 Jun 2010 14:45:34 +0100 Howard Page-Clark wrote: > On 08/6/10 8:10, Mattias Gaertner wrote: >> On Mon, 07 Jun 2010 23:54:22 +0100 >> Howard Page-Clark wrote: >> >>> There is a minor bug in the very useful example application dircleaner. >>> The unit dircleaner.pp around line 441 has >>> >>> FileNameFits:=Pos(Ext,FWorkExt)0; >>> >>> to check if the current file under consideration fits the specified file >>> extension. >>> >>> This test is too simple since it does not look for an exact match. >>> Suppose FWorkExt contains 'PPU' and the current file extension is 'PP'. >>> >>> The program will delete all the .pp files it finds, as well as all the >>> .ppu ones. The test has to be stricter. >> >> I improved it. Please test. > > Your improvement fixes that bug, thanks. > However I could not get the confdirs project to compile and run without > errors on Windows 7 until I commented out > > confdirs.lpr line 15 {$R manifest.res} Fixed. Please test under windows7

Now compiles fine under Windows 7.

Show quoted text 16 lines
> frmmain.pp line 870 writeln('Adding', Loc[i].Name); Fixed. > Also the FileActions tabsheet of the main config pagecontrol does not > work properly. New actions are not shown, or the app crashes if an > 'invisible' (but selected) action is deleted. I see that frmmain.pp line > 990 has this comment in the method ShowFileActionItem(LI: TListItem): > > // Bug in control: the items list is cleared!! > // UpdateActionLocations(FLocations); > > Is the source of this bug known, and if so is the bug in the bugtracker? Please create a bug report.

Bug report created 10.6.2010

Howard

Reply by email

Maxim Ganetsky
to Unknown author: Mattias Gaertner wrote on 06/10/2010 12:42:58 PM: Only on 0.9.30+ IIRC. If you have an…

10.06.2010 20:59, ?????:

Show quoted text 26 lines
Mattias Gaertner wrote on 06/10/2010 12:42:58 PM: > > 06/10/2010 12:43 PM > > > On Thu, 10 Jun 2010 16:31:51 +0000 > "K. P." wrote: > > > > > > > Hi all ~ > > am in the process of converting one of our win32 delphi apps to > lazarus/cross platform. > > Converting something trivial like > > ShellExecute( 0, nil, PChar( url ), nil, nil, SW_SHOWDEFAULT ); > > How can I find the default browser (if any) on supported platforms? > > unit LCLIntf function OpenURL > > Mattias > Only on 0.9.30+ IIRC. If you have an earlier version I believe you have to jump thru the hoops as documented in the wiki article(s).

It is available in 0.9.28.3 and 0.9.29.

Best regards, Maxim Ganetsky mailto:

Reply by email

K. P.
to Maxim Ganetsky

Hi all ~
in Delphi I can create horizontal menu dividers by setting the caption of a menu item to '-' - this does not seem to be supported by Lazarus - any other way this can be done? ThanksKP
_________________________________________________________________ Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100610/30c05b9f/attachment.html>

Reply by email

dmitry boyarintsev
to K. P.

2010/6/10 K. P. :

in Delphi I can create horizontal menu dividers by setting the caption of a menu item to '-' - this does not seem to be supported by Lazarus - any other way this can be done?

It's supported in Lazarus
Just set caption to '-'

thanks,
dmitry

Reply by email

Leonardo M. Ramé
to Maxim Ganetsky: 10.06.2010 20:59, ?????: It is available in 0.9.28.3 and 0.9.29. Maxim Ganetsky …

Hi, I'm trying to implement file downloading for an fpWeb CGI without success, I'm doing this so far:

procedure TFPWebModule1.TFPWebActions0Request(Sender: TObject;
  ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);
var
  lImage: string;
  lFileStream: TFileStream;
begin
    lImage := '/home/leonardo/files/file1.dcm';
    lFileStream := TFileStream.Create(lImage, fmShareDenyNone);
    try
      AResponse.ContentType := 'image/dicom3';
      AResponse.CustomHeaders.Values['Content-Disposition'] :=
        'attachment; filename=' + ExtractFileName(lImage);
      AResponse.LoadFromStream(lFileStream, True);
      AResponse.SendContent; // not sure if this is needed.
    finally
      lFileStream.Free;
    end;
  Handled := True;
end;

And the results of curl are this:

* About to connect() to localhost port 80 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 80 (#0)

GET /cgi-bin/getstudy/StudyId?IdSeries=1 HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7

OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15

Host: localhost Accept: */*

< HTTP/1.1 200 OK
< Date: Thu, 10 Jun 2010 20:17:52 GMT
< Server: Apache/2.2.14 (Ubuntu)
< Content-Disposition: attachment; filename=MR_4c1139a4b76d62c2.dcm < Content-Length: 0
< Content-Type: image/dicom3
<
* Connection #0 to host localhost left intact
* Closing connection #0

As you can see, the Content-Lenght is 0, and the image isn't downloaded. What is the correct way of implementing this?.

Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979

Reply by email

Leonardo M. Ramé
to Leonardo M. Ramé

El jue, 10-06-2010 a las 17:23 -0300, Leonardo M. Ram? escribi?:

Show quoted text 47 lines
Hi, I'm trying to implement file downloading for an fpWeb CGI without success, I'm doing this so far: procedure TFPWebModule1.TFPWebActions0Request(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); var lImage: string; lFileStream: TFileStream; begin lImage := '/home/leonardo/files/file1.dcm'; lFileStream := TFileStream.Create(lImage, fmShareDenyNone); try AResponse.ContentType := 'image/dicom3'; AResponse.CustomHeaders.Values['Content-Disposition'] := 'attachment; filename=' + ExtractFileName(lImage); AResponse.LoadFromStream(lFileStream, True); AResponse.SendContent; // not sure if this is needed. finally lFileStream.Free; end; Handled := True; end; And the results of curl are this: * About to connect() to localhost port 80 (#0) * Trying ::1... connected * Connected to localhost (::1) port 80 (#0) > GET /cgi-bin/getstudy/StudyId?IdSeries=1 HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15 > Host: localhost > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 10 Jun 2010 20:17:52 GMT < Server: Apache/2.2.14 (Ubuntu) < Content-Disposition: attachment; filename=MR_4c1139a4b76d62c2.dcm < Content-Length: 0 < Content-Type: image/dicom3 < * Connection #0 to host localhost left intact * Closing connection #0 As you can see, the Content-Lenght is 0, and the image isn't downloaded. What is the correct way of implementing this?.

Sorry, I found the solution (I just needed to create an instance of AResponse.ContentStream):

AResponse.ContentStream :=  TFileStream.Create(lImage, fmShareDenyNone);
try
  AResponse.ContentType := 'image/dicom3';
  AResponse.CustomHeaders.Values['Content-Disposition'] := 'attachment;
filename=' + ExtractFileName(lImage);
  AResponse.ContentLength := AResponse.ContentStream.Size;
  AResponse.SendContent;
finally
   AResponse.ContentStream.Free;
end;
Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979

Reply by email

ABorka
to Leonardo M. Ramé
Leonardo M. Ram? wrote 62 lines
El jue, 10-06-2010 a las 17:23 -0300, Leonardo M. Ram? escribi?: > Hi, I'm trying to implement file downloading for an fpWeb CGI without > success, I'm doing this so far: > > procedure TFPWebModule1.TFPWebActions0Request(Sender: TObject; > ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); > var > lImage: string; > lFileStream: TFileStream; > begin > lImage := '/home/leonardo/files/file1.dcm'; > lFileStream := TFileStream.Create(lImage, fmShareDenyNone); > try > AResponse.ContentType := 'image/dicom3'; > AResponse.CustomHeaders.Values['Content-Disposition'] := > 'attachment; filename=' + ExtractFileName(lImage); > AResponse.LoadFromStream(lFileStream, True); > AResponse.SendContent; // not sure if this is needed. > finally > lFileStream.Free; > end; > Handled := True; > end; > > And the results of curl are this: > > * About to connect() to localhost port 80 (#0) > * Trying ::1... connected > * Connected to localhost (::1) port 80 (#0) >> GET /cgi-bin/getstudy/StudyId?IdSeries=1 HTTP/1.1 >> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 > OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15 >> Host: localhost >> Accept: */* >> > < HTTP/1.1 200 OK > < Date: Thu, 10 Jun 2010 20:17:52 GMT > < Server: Apache/2.2.14 (Ubuntu) > < Content-Disposition: attachment; filename=MR_4c1139a4b76d62c2.dcm > < Content-Length: 0 > < Content-Type: image/dicom3 > < > * Connection #0 to host localhost left intact > * Closing connection #0 > > As you can see, the Content-Lenght is 0, and the image isn't downloaded. > What is the correct way of implementing this?. > Sorry, I found the solution (I just needed to create an instance of AResponse.ContentStream): AResponse.ContentStream := TFileStream.Create(lImage, fmShareDenyNone); try AResponse.ContentType := 'image/dicom3'; AResponse.CustomHeaders.Values['Content-Disposition'] := 'attachment; filename=' + ExtractFileName(lImage); AResponse.ContentLength := AResponse.ContentStream.Size; AResponse.SendContent; finally AResponse.ContentStream.Free; end;
The filename might need to be between double quotes, like
AResponse.CustomHeaders.Add('Content-Disposition= attachment;
filename="blah blah.csv"');

because there might be some spaces in the name for example.

Also, I am not sure but does the AResponse.ContentStream need to be freed after the SendContent or SendResponse? If I remember right, back it old delphi days with the proper way, the stream was not freed. Not sure how it works in FPC/Lazarus though.

AB

Reply by email

Michael Van Canneyt
to ABorka: The filename might need to be between double quotes, like…
ABorka wrote 74 lines
On 6/10/2010 13:30, Leonardo M. Ram? wrote: > El jue, 10-06-2010 a las 17:23 -0300, Leonardo M. Ram? escribi?: >> Hi, I'm trying to implement file downloading for an fpWeb CGI without >> success, I'm doing this so far: >> >> procedure TFPWebModule1.TFPWebActions0Request(Sender: TObject; >> ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); >> var >> lImage: string; >> lFileStream: TFileStream; >> begin >> lImage := '/home/leonardo/files/file1.dcm'; >> lFileStream := TFileStream.Create(lImage, fmShareDenyNone); >> try >> AResponse.ContentType := 'image/dicom3'; >> AResponse.CustomHeaders.Values['Content-Disposition'] := >> 'attachment; filename=' + ExtractFileName(lImage); >> AResponse.LoadFromStream(lFileStream, True); >> AResponse.SendContent; // not sure if this is needed. >> finally >> lFileStream.Free; >> end; >> Handled := True; >> end; >> >> And the results of curl are this: >> >> * About to connect() to localhost port 80 (#0) >> * Trying ::1... connected >> * Connected to localhost (::1) port 80 (#0) >>> GET /cgi-bin/getstudy/StudyId?IdSeries=1 HTTP/1.1 >>> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 >> OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15 >>> Host: localhost >>> Accept: */* >>> >> < HTTP/1.1 200 OK >> < Date: Thu, 10 Jun 2010 20:17:52 GMT >> < Server: Apache/2.2.14 (Ubuntu) >> < Content-Disposition: attachment; filename=MR_4c1139a4b76d62c2.dcm >> < Content-Length: 0 >> < Content-Type: image/dicom3 >> < >> * Connection #0 to host localhost left intact >> * Closing connection #0 >> >> As you can see, the Content-Lenght is 0, and the image isn't downloaded. >> What is the correct way of implementing this?. >> > > Sorry, I found the solution (I just needed to create an instance of > AResponse.ContentStream): > > AResponse.ContentStream := TFileStream.Create(lImage, fmShareDenyNone); > try > AResponse.ContentType := 'image/dicom3'; > AResponse.CustomHeaders.Values['Content-Disposition'] := 'attachment; > filename=' + ExtractFileName(lImage); > AResponse.ContentLength := AResponse.ContentStream.Size; > AResponse.SendContent; > finally > AResponse.ContentStream.Free; > end; The filename might need to be between double quotes, like AResponse.CustomHeaders.Add('Content-Disposition= attachment; filename="blah blah.csv"'); because there might be some spaces in the name for example. Also, I am not sure but does the AResponse.ContentStream need to be freed after the SendContent or SendResponse? If I remember right, back it old delphi days with the proper way, the stream was not freed. Not sure how it works in FPC/Lazarus though.

If you use ContentStream, you must free it manually.

Michael.

Reply by email