Read from a file opened with O_WRONLY - file-io

Is it possible to read from a file which is opened using open system call with O_WRONLY flag in Unix?. If it is possible then what does Write Only (O_WRONLY) mean??
Thanks,
LinuxPenseur

Yes, it's possible, just not with the file descriptor returned from that open() call.

Duh. Oh course write-only means exactly that — write ONLY.

Related

How collect failed address in Exim?

How save to file email if you can not deliver the message?
Or the only way is to log analysis?
Thank you!
Yes, You can check that with the command line. Here are the some useful link for you.
http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
http://bradthemad.org/tech/notes/exim_cheatsheet.php

AudioServicesCreateSystemSoundID URL

In this call:
AudioServicesCreateSystemSoundID((CFURLRef)urlSound, &audioID);
does urlSound have to be a local file? I am passing in a wav file on a website but it's returning 0. Is that why?
Thanks
Yes.
(The URL is converted using CFURLGetFileSystemRepresentation and then opened with the standard UNIX open(2) function, so it's pretty sure that URL should point to a local file.)

Advanced Cocoa Category - catching all file access - iOS

Hey Guys,
In my app i need to verify that the file actually exist on the device before its being accessed by some file access methods (UIImage imageNamed, Cocos2d CCSprite method and so on).
I need to be sure that the file is on the device (and if not try to fetch it from the servers).
Can I do it without changing all the code to support it?
I thought on something like a 'Super Category' on the file system...
Is it possible???
I saw this idea, what do you think
overriding-methods-in-cocoa-without-subclassing
Thanks!
M.
it's often best to attempt the file/url read and fail gracefully - filesystems have a way of changing.
if you know the image's bundle, then use NSBundle.
You could use NSFileManager fileExistsAtPath: but from the docs:
/* The following methods are of limited utility. Attempting to predicate behavior based on the current state of the filesystem or a particular file on the filesystem is encouraging odd behavior in the face of filesystem race conditions. It's far better to attempt an operation (like loading a file or creating a directory) and handle the error gracefully than it is to try to figure out ahead of time whether the operation will succeed.
So probably just try to get the resource, if it fails, fetch and then retry.

Is it nessary to call servicehost.close method before the host application ends

I am wondering if it is necessary to call servicehost.close before the application ends?
I would use the close and I avoid a using block after reading this article
http://www.danrigsby.com/blog/index.php/2008/02/26/dont-wrap-wcf-service-hosts-or-clients-in-a-using-statement/

powershell - check if pdf is encrypted

Using powershell I need to loop a series of pdf file and make some operation on them using pdftk. I'd like to know if exists some method to detect if pdf is encrypted or not. In this way, if the pdf is encrypted I don't work on it and my loop skips to the next file. Thanks for the attention.
edit. While I wait for some answer I've found that itextsharp has an isencrypted method.
After I load the assembly
[System.Reflection.Assembly]::LoadFrom("c:\my_path\itextsharp.dll")
what do I have to do to use the above method?
[System.Reflection.Assembly]::LoadFrom("c:\itext\itextsharp.dll")
$itext = new-object itextsharp.text.pdf.PdfReader("c:\itext\1.pdf")
$itext.isEncrypted()
You should get either true or false as a result.
For the people that reach this page searching for a way to check if files are NTFS encrypted, this is the way to go:
[System.IO.File]::GetAttributes($RootFolder).ToString().Contains("Encrypted")