Re: Open File - Read Only



On Sep 27, 8:49 pm, andrewmchor...@xxxxxxx wrote:

I appreciate the response to the last question. I have scripts that I have opened
files and they work. However, I am failing on opens now because the file is read
only. What is the way to open a file read only.

If you are trying to open the file for reading, you just open the file
like you would any other time. There's no difference.

If you're trying to open the file for writing or appending, you
can't. They're READ-only. You're not allowed to open them for
writing or appending. That's the whole point of a read-only file. If
you don't want the file to be read-only, you need to change its
permissions (which is Operating System-dependent, and has nothing to
do with Perl).

Paul Lalli



.



Relevant Pages

  • Re: who to use fwrite to write through a hidden file
    ... It opens a file, and NEGLECTS TO SEE IF THE OPEN WORKED! ... You have no reason to assume this could work. ... Let me put it this way: I would not consider writing such a piece of code. ... how can you be trusted to modify something as critical as ...
    (microsoft.public.vc.mfc)
  • Re: comparison with None
    ... This seems to go entirely against the spirit of the language. ... For example, if you expect an open file handle, but get a NoneType because you didn't really open a file, then it would be best to test the type of return object before using it. ... I am aware that this opens the gates to the hordes who will now pile in pointing out that this will technique will fail if f is zero or one of the many other items that evaluates to false in a Boolean context. ... It's that poor readability that Steven D'Aprano was making fun of in his remarks above, which in truth only echoes what I felt like but refrained from writing when I pointed out the redundancy in the ...
    (comp.lang.python)
  • Re: just a simple question re: ifstream
    ... >> We know that, when using ifstream to open a file for input, a file is ... > opening a file for writing with an ofstream, in which case the default behavior ... >> opens a file that does exist? ... the filename of the hex file he/she would like to load into the ...
    (comp.lang.cpp)
  • Re: Behavior of fwrite(), fseek(), fflush() if the file gets deleted after being opened.
    ... I am writing an application in C with file handling. ... opens a fileusing fopenin binary write ... The C standard doesn't specify what happens when one process is access ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: Writing to a named pipe imposible if there is no reading process running
    ... >out of that pipe and writing the contents to a text file. ... Standard behaviour wjhen opening a FIFO is this: ... opening the FIFO for writing blocks until another process opens the ...
    (comp.os.linux.development.apps)