It is currently Thu Dec 05, 2019 6:39 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sat Aug 31, 2019 3:39 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 375
Location: Germany
PB help wrote:
Opens a file for reading/writing or creates a new file if it does not exist.
It would be good if the command had a flag that could disable the creation of a new file.
If the file does not exist then #False should be returned.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sat Aug 31, 2019 3:53 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Jul 23, 2011 1:13 am
Posts: 221
Location: Germany
Use
Code:
If FileSize(path) > -1 ;only open the file if it already exists
    OpenFile(fileID, path)
Endif


If there's a flag, PB needs to check if the file exists, anyway, so it's probably not even faster to have it as a flag, versus what you can already do with a single If


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sat Aug 31, 2019 4:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 375
Location: Germany
Yes, there are always workarounds, but in my opinion the command should support that natively.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sat Aug 31, 2019 4:17 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3715
Location: Berlin, Germany
Sicro wrote:
If the file does not exist then #False should be returned.

E.g. the name #PB_File_Existing would be more intuitive then. :-)

File existing?
Yes --> #True
No --> #False

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sat Aug 31, 2019 10:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 375
Location: Germany
@Little John:
You mean it should work the other way around: Instead of disabling the creation of the file with the flag #PB_File_NoCreate, there should be a flag #PB_File_Existing that enables the creation?

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sat Aug 31, 2019 11:39 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3715
Location: Berlin, Germany
Sicro wrote:
@Little John:
You mean it should work the other way around: Instead of disabling the creation of the file with the flag #PB_File_NoCreate, there should be a flag #PB_File_Existing that enables the creation?

No, I don't mean that. That would be a different feature request. :-)

I mean: If Fred will implement what you are asking for, then the new flag shold be named e.g. #PB_File_Existing (short for #PB_Open_Only_An_Already_Existing_File) rather than #PB_File_NoCreate.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: OpenFile(): Add flag #PB_File_NoCreate
PostPosted: Sun Sep 01, 2019 11:14 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 375
Location: Germany
Little John wrote:
#PB_File_Existing (short for #PB_Open_Only_An_Already_Existing_File) rather than #PB_File_NoCreate
Okay, I'm fine with that, too.

_________________
Image
Why OpenSource should have a license
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download -- Any help is welcome!
Manjaro Xfce x64 (Main system) :: WindowsXP/Xubuntu x86 (VirtualBox) :: PureBasic (Linux: x86/x64, Windows: x86) :: All are up to date


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye