Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: open(): Is there a simple way to map between numeric open modes and "symbol modes"?

by BrowserUk (Pope)
on Feb 08, 2013 at 03:24 UTC ( #1017751=note: print w/ replies, xml ) Need Help??


in reply to Re^2: open(): Is there a simple way to map between numeric open modes and "symbol modes"?
in thread open(): Is there a simple way to map between numeric open modes and "symbol modes"? (solved)

how do I un-OR OR results, against the other flags, to get back to these basic constants?

(From MSVC header files:

#define _O_RDONLY 0x0000 /* open for reading only */ #define _O_WRONLY 0x0001 /* open for writing only */ #define _O_RDWR 0x0002 /* open for reading and writing */ #define _O_APPEND 0x0008 /* writes done at eof */ #define _O_CREAT 0x0100 /* create and open file */ #define _O_TRUNC 0x0200 /* open and truncate */ #define _O_EXCL 0x0400 /* open only if file doesn't already e +xist */ #define _O_TEXT 0x4000 /* file mode is text (translated) */ #define _O_BINARY 0x8000 /* file mode is binary (untranslated) +*/ #define _O_WTEXT 0x10000 /* file mode is UTF16 (translated) */ #define _O_U16TEXT 0x20000 /* file mode is UTF16 no BOM (translat +ed) */ #define _O_U8TEXT 0x40000 /* file mode is UTF8 no BOM (translat +ed) */

So, assuming the variable $mode contains the OR'd values; you can check which bits are set something like:

if( $mode & 1 ) { ## _O_WRONLY say "File is opend WRITE only }

But note: not all of the bits that can be set when opening a file are retained in FILE*->_flag.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: open(): Is there a simple way to map between numeric open modes and "symbol modes"?
Select or Download Code
Re^4: open(): Is there a simple way to map between numeric open modes and "symbol modes"?
by isync (Hermit) on Feb 08, 2013 at 14:06 UTC
    Thumbs up for this load of code!! Thank you BrowserUk!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-07-03 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls