Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
unix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rinat Striungis
unix
Commits
b495e1d8
Commit
b495e1d8
authored
9 years ago
by
Herbert Valerio Riedel
Browse files
Options
Downloads
Patches
Plain Diff
Use `#const` rather than FFI wrapper for PATH_MAX
This has the side-effect of making two more modules `Safe`-inferred
parent
57d2cb2a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
System/Posix/Directory.hsc
+10
-4
10 additions, 4 deletions
System/Posix/Directory.hsc
System/Posix/Directory/ByteString.hsc
+10
-4
10 additions, 4 deletions
System/Posix/Directory/ByteString.hsc
cbits/HsUnix.c
+0
-12
0 additions, 12 deletions
cbits/HsUnix.c
include/HsUnix.h
+0
-6
0 additions, 6 deletions
include/HsUnix.h
with
20 additions
and
26 deletions
System/Posix/Directory.hsc
+
10
−
4
View file @
b495e1d8
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE NondecreasingIndentation #-}
#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- |
...
...
@@ -18,6 +22,11 @@
#include "HsUnix.h"
-- hack copied from System.Posix.Files
#if !defined(PATH_MAX)
# define PATH_MAX 4096
#endif
module System.Posix.Directory (
-- * Creating and removing directories
createDirectory, removeDirectory,
...
...
@@ -115,7 +124,7 @@ foreign import ccall unsafe "__hscore_d_name"
-- | @getWorkingDirectory@ calls @getcwd@ to obtain the name
-- of the current working directory.
getWorkingDirectory :: IO FilePath
getWorkingDirectory = go
long_path_size
getWorkingDirectory = go
(#const PATH_MAX)
where
go bytes = do
r <- allocaBytes bytes $ \buf -> do
...
...
@@ -134,9 +143,6 @@ getWorkingDirectory = go long_path_size
foreign import ccall unsafe "getcwd"
c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar)
foreign import ccall unsafe "__hsunix_long_path_size"
long_path_size :: Int
-- | @changeWorkingDirectory dir@ calls @chdir@ to change
-- the current working directory to @dir@.
changeWorkingDirectory :: FilePath -> IO ()
...
...
This diff is collapsed.
Click to expand it.
System/Posix/Directory/ByteString.hsc
+
10
−
4
View file @
b495e1d8
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE NondecreasingIndentation #-}
#if __GLASGOW_HASKELL__ >= 709
{-# LANGUAGE Safe #-}
#else
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- |
...
...
@@ -18,6 +22,11 @@
#include "HsUnix.h"
-- hack copied from System.Posix.Files
#if !defined(PATH_MAX)
# define PATH_MAX 4096
#endif
module System.Posix.Directory.ByteString (
-- * Creating and removing directories
createDirectory, removeDirectory,
...
...
@@ -116,7 +125,7 @@ foreign import ccall unsafe "__hscore_d_name"
-- | @getWorkingDirectory@ calls @getcwd@ to obtain the name
-- of the current working directory.
getWorkingDirectory :: IO RawFilePath
getWorkingDirectory = go
long_path_size
getWorkingDirectory = go
(#const PATH_MAX)
where
go bytes = do
r <- allocaBytes bytes $ \buf -> do
...
...
@@ -135,9 +144,6 @@ getWorkingDirectory = go long_path_size
foreign import ccall unsafe "getcwd"
c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar)
foreign import ccall unsafe "__hsunix_long_path_size"
long_path_size :: Int
-- | @changeWorkingDirectory dir@ calls @chdir@ to change
-- the current working directory to @dir@.
changeWorkingDirectory :: RawFilePath -> IO ()
...
...
This diff is collapsed.
Click to expand it.
cbits/HsUnix.c
+
0
−
12
View file @
b495e1d8
...
...
@@ -36,18 +36,6 @@ int __hsunix_push_module(int fd, const char *module)
#endif
}
/* A size that will contain many path names, but not necessarily all
* (PATH_MAX is not defined on systems with unlimited path length,
* e.g. the Hurd).
*/
HsInt
__hsunix_long_path_size
(
void
)
{
#ifdef PATH_MAX
return
PATH_MAX
;
#else
return
4096
;
#endif
}
/*
* read an entry from the directory stream; opt for the
* re-entrant friendly way of doing this, if available.
...
...
This diff is collapsed.
Click to expand it.
include/HsUnix.h
+
0
−
6
View file @
b495e1d8
...
...
@@ -116,10 +116,4 @@ fall back to O_FSYNC, which should be the same */
// push a SVR4 STREAMS module; do nothing if STREAMS not available
int
__hsunix_push_module
(
int
fd
,
const
char
*
module
);
/* A size that will contain many path names, but not necessarily all
* (PATH_MAX is not defined on systems with unlimited path length,
* e.g. the Hurd).
*/
HsInt
__hsunix_long_path_size
();
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment