
Hello, I tried d to use Hoogle to find openFd's signature and more importantly FileMode. I found FileMode which is a type synonym with CMode. I don't understand what are the "values" for FileMode (so I can call openFd). ?? Thanks, Vasili

2008/4/16 Galchin, Vasili
Hello,
I tried d to use Hoogle to find openFd's signature and more importantly FileMode. I found FileMode which is a type synonym with CMode. I don't understand what are the "values" for FileMode (so I can call openFd). ??
Values of type FileMode are defined in System.Posix.Files See http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.ht... for the defintions. Does that help? -Antoine

hi Antoine,
I already found this link. Thanks in any case. I want to O_CREATE a file,
i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I
don't see in the link below.
Thanks, Vasili
On Wed, Apr 16, 2008 at 1:46 PM, Antoine Latter
2008/4/16 Galchin, Vasili
: Hello,
I tried d to use Hoogle to find openFd's signature and more importantly FileMode. I found FileMode which is a type synonym with CMode. I don't understand what are the "values" for FileMode (so I can call openFd). ??
Values of type FileMode are defined in System.Posix.Files
See http://haskell.org/ghc/docs/latest/html/libraries/unix/System-Posix-Files.ht... for the defintions.
Does that help?
-Antoine

Hi Vasili,
I already found this link. Thanks in any case. I want to O_CREATE a file, i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I don't see in the link below.
What do you want to do beyond writeFile/openFile/readFile? If you can, its better to use the standard IO openFile. Thanks Neil

On Wed April 16 2008 3:54:45 pm Galchin, Vasili wrote:
hi Antoine,
I already found this link. Thanks in any case. I want to O_CREATE a file, i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I don't see in the link below.
Indeed. It seems there is no way to pass O_CREAT to openFile. there is createFile, but that's really a different call. Sigh.

On Wed, Apr 16, 2008 at 5:30 PM, John Goerzen
On Wed April 16 2008 3:54:45 pm Galchin, Vasili wrote:
hi Antoine,
I already found this link. Thanks in any case. I want to O_CREATE a file, i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I don't see in the link below.
Indeed. It seems there is no way to pass O_CREAT to openFile. there is createFile, but that's really a different call. Sigh.
In openFile, in GHC 6.8.2 at least, O_CREAT is passed for WriteMode and ReadWriteMode -- see output_flags in GHC/Handle.hs. Graham

On Apr 16, 2008, at 17:30 , John Goerzen wrote:
On Wed April 16 2008 3:54:45 pm Galchin, Vasili wrote:
I already found this link. Thanks in any case. I want to O_CREATE a file, i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I don't see in the link below.
Indeed. It seems there is no way to pass O_CREAT to openFile. there is createFile, but that's really a different call. Sigh.
Remember, Haskell is functional; treat the function to call as an argument? -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Wednesday 16 April 2008 6:16:56 pm Brandon S. Allbery KF8NH wrote:
On Apr 16, 2008, at 17:30 , John Goerzen wrote:
On Wed April 16 2008 3:54:45 pm Galchin, Vasili wrote:
I already found this link. Thanks in any case. I want to O_CREATE a file, i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I don't see in the link below.
Indeed. It seems there is no way to pass O_CREAT to openFile. there is createFile, but that's really a different call. Sigh.
Remember, Haskell is functional; treat the function to call as an argument?
I don't have access to the GHC source just at the moment, but presumably that is an interface to creat() instead of open(). creat() is documented as: creat() is equivalent to open() with flags equal to O_CREAT|O_WRONLY|O_TRUNC. There could be reasons that you would want to pass, say, O_CREAT|O_RDWR| O_APPEND and omit O_TRUNC. There are also reasons that you might want to pass, say, O_WRONLY|O_APPEND with no O_CREAT. The fact that openFile implies O_CREAT sometimes is a serious misfeature IMHO. That means bug. -- John

On Wed April 16 2008 6:16:56 pm Brandon S. Allbery KF8NH wrote:
On Apr 16, 2008, at 17:30 , John Goerzen wrote:
On Wed April 16 2008 3:54:45 pm Galchin, Vasili wrote:
I already found this link. Thanks in any case. I want to O_CREATE a file, i.e. do a openFd creating a new file. O_CREATE should be the FileMode, but I don't see in the link below.
Indeed. It seems there is no way to pass O_CREAT to openFile. there is createFile, but that's really a different call. Sigh.
Remember, Haskell is functional; treat the function to call as an argument?
That misses the point; the two are different calls in C and full functionality is not exposed via the Haskell API. -- John

Hi
I tried d to use Hoogle to find openFd's signature and more importantly FileMode.
Hoogle does not search the Posix library, because in general people should steer clear of it - otherwise I won't be able to run your programs :-) - The next version of Hoogle will permit selecting to search the Posix library, if you so choose.
I found FileMode which is a type synonym with CMode. I don't understand what are the "values" for FileMode (so I can call openFd). ??
Clearly, the documentation is rather weak. It comes from the Posix "open" function, which is document all over the place, and you can see the code here: http://darcs.haskell.org/ghc-6.6/packages/unix/System/Posix/IO.hsc After figuring out what you want, I recommend submitting a patch for documentation. Additionally, if what you want can be done in a cross platform way, but lacks the appropriate abstraction layer, I would add a request for this to be fixed. Thanks Neil
participants (6)
-
Antoine Latter
-
Brandon S. Allbery KF8NH
-
Galchin, Vasili
-
Graham Fawcett
-
John Goerzen
-
Neil Mitchell