Recent

Author Topic: [SOLVED] Sysutils.GetTempfile seems to return empty file  (Read 5236 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
[SOLVED] Sysutils.GetTempfile seems to return empty file
« on: July 03, 2013, 07:52:23 am »
This code in my patchwrangler project (patchmanagement.pas, around line 369):
Code: [Select]
      TempPatchFile := SysUtils.GetTempFilename(GetTempDir(false), 'pmg');
      //Note: SysUtils.GetTempFileName('','') doesn't seem to work!?!?
      if TempPatchFile = '' then
      begin
        {$IFDEF DEBUG}
        FLog.Add('Debug: FindCandidates: GetTempFileName failed; IOResult: '+inttostr(IOResult));
        {$ENDIF DEBUG}
        {$IFDEF UNIX}
        TempPatchFile:='/tmp/pw'+Chr(97+(Random(25)))+Chr(97+(Random(25)))+Chr(97+(Random(25)));
        {$ELSE}
        FLog.Add('Could not get temporary file. Aborting');
        Exit(false);
        {$ENDIF UNIX}
      end;
      Assert(TempPatchFile<>'', 'Sysutils.GetTempFileName must return a file name'); //seems to be a problem on Linux!??!
REFUSES to produce a temp filename. FPC fixes 2.6, Laz trunk, both on Win x86 and Linux x86.

Is it me again?

You can download the patchwrangler project source [1] and run it. On Windows the log will say
Quote
Could not get temporary file. Aborting

[1]
https://bitbucket.org/reiniero/patchwrangler/downloads
select branches, download.
« Last Edit: July 03, 2013, 11:06:39 am by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Sysutils.GetTempfile seems to return empty file
« Reply #1 on: July 03, 2013, 09:20:15 am »
Does using ExcludeTrailingBackslash(GetTempDir(false)) help?

EDIT: SysUtils.GetTempFilename(GetTempDir(false), 'pmg') works for me. Free Pascal trunk 2.7.1-r24977, Lazarus trunk 1.1-r41950
« Last Edit: July 03, 2013, 09:25:09 am by Cyrax »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sysutils.GetTempfile seems to return empty file
« Reply #2 on: July 03, 2013, 09:22:43 am »
@Cyrax, tried:
Code: [Select]
      TempPatchFile := SysUtils.GetTempFilename(ExcludeTrailingPathDelimiter(GetTempDir(false)), 'pmg');
... didn't help any.

Also tried
Code: [Select]
TempPatchFile := SysUtils.GetTempFilename('', 'pmg');
without success.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Sysutils.GetTempfile seems to return empty file
« Reply #3 on: July 03, 2013, 09:31:09 am »
Hmm, strange.

Just checked out, FPC fixes works here. Free Pascal trunk 2.6.3-r24984, Lazarus trunk 1.1 r41933.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sysutils.GetTempfile seems to return empty file
« Reply #4 on: July 03, 2013, 09:34:04 am »
Thanks Cyrax. Mmmph. Guess I'll have to double check my FPC version...
Edit: oops, yes, I wasn't uses fixes 2.6 but FPC trunk for some compiles in order to try and debug. I'll give it another go with Laz 1.0.10/FPC 2.6.2
« Last Edit: July 03, 2013, 09:37:34 am by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sysutils.GetTempfile seems to return empty file
« Reply #5 on: July 03, 2013, 09:39:28 am »
Just ran delp ., removed all .exe and .obj files, recompiled with Laz 1.0.10/FPC 2.6.2 x86 Windows... same problem...

@Cyrax: what OS did you test it on?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Sysutils.GetTempfile seems to return empty file
« Reply #6 on: July 03, 2013, 09:48:28 am »
Windows Server 2008 R2. I'm on admin account and my temp file directory location is system wide one. With necessary security permissions applied on it.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sysutils.GetTempfile seems to return empty file
« Reply #7 on: July 03, 2013, 09:51:15 am »
Ok, thanks.

I'm on Win 7, admin.

Guess it's time to test it on an older Windows version to make sure...
(Strange that it happens on my Debian Linux unstable as well though)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [SOLVED] Sysutils.GetTempfile seems to return empty file
« Reply #8 on: July 03, 2013, 11:07:46 am »
Solved thanks to Juha's help (see patchwrangler thread in the Third Party subforum).

As usual, PEBKAC/PICNIC involved - having an {$IFDEF} that influenced the program flow.

@Cyrax: thanks for the help!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018