Skip to content

Make Permissions type abstract

The Permissions type in System.Directory aims to be a lowest-common-denominator type. This makes it unsuitable for some tasks. For example, a copyPermissions primitive had to be implemented, as it is not possible to use the getPermissions and setPermissions functions to copy the permissions from one file to another:

$ ls -l foo*
-rwxr-x-wx 1 ian ian 0 Jun 23 21:27 foo1
---------- 1 ian ian 0 Jun 23 21:27 foo2
---------- 1 ian ian 0 Jun 23 21:27 foo3
$ hd -e 'System.Directory.copyPermissions "foo1" "foo2"'
$ hd -e 'System.Directory.getPermissions "foo1" >>= System.Directory.setPermissions "foo3"'
$ ls -l foo*                                            
-rwxr-x-wx 1 ian ian 0 Jun 23 21:27 foo1
-rwxr-x-wx 1 ian ian 0 Jun 23 21:27 foo2
-rwx------ 1 ian ian 0 Jun 23 21:27 foo3

I think we would be better served by the Permissions type being abstract in System.Directory, with the unix and Win32 packages providing the real definition, and some system-specific functions on it. This would allow the generic get/set functions to implement copyPermissions.

This proposal just does the step which has most potential to cause problems for packages that use the type: It makes the type abstract in System.Directory (and adds explicit setter functions, so no functionality is lost).

The type is also exported in Haskell 98's Directory module. I think this should get its own copy of the type.

Suggested discussion deadline: 9 July 2010.

Trac metadata
Trac field Value
Version 6.12.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/directory
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information