-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More preparation for Cabal, name change
Ignore-this: e6bc8fae96ff29b5abf5e89591ed1e9a -Changed module name to Tree, so that it will reside in System.Directory.Tree -finished .cabal file -other adjustments to DirectoryTree interface/exports darcs-hash:20090508212743-a5925-b08d39e13d59b220953c689d9acd71785dbd6e54
- Loading branch information
Showing
4 changed files
with
153 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright (c) 2009 Brandon Simmons | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: directory-tree | ||
version: 0.1 | ||
homepage: http://code.haskell.org/~bsimmons/code/directory-tree | ||
synopsis: A simple directory-like tree datatype, with useful IO functions and Foldable/Traversable instance | ||
description: A simple directory-like tree datatype, with useful IO functions and Foldable/Traversable instance | ||
. | ||
Provides a simple data structure mirroring a directory tree on the | ||
filesystem, as well as useful functions for reading and writing | ||
file/directory structures in the IO monad. | ||
. | ||
Importing the library and optional (useful) Foldable and Traverable libraries: | ||
. | ||
> import System.Directory.Tree | ||
> import qualified Data.Foldable as F | ||
> import qualified Data.Traversable as T | ||
. | ||
Write a hand-made directory tree of textfiles (strings) to the disk. | ||
Simulates creating a new user Tux's home directory on a unix machine: | ||
. | ||
> writeDirectory$ "/home" :/ Dir "Tux" [File "README" "Welcome!"] | ||
. | ||
"read" a directory by opening all the files at a filepath with readFile, | ||
returning an 'AnchoredDirTree String' (d2). Then check for any IO failures: | ||
. | ||
> do (base :/ d2) <- readDirectory "../parent_dir/dir2/" | ||
> let failed = anyFailed d2 | ||
> if failed then ... | ||
. | ||
Use Foldable instance function to concat a directory 'dir' of text files into a | ||
single file under the same directory: | ||
. | ||
> do (b :/ dt) <- readDirectory dir | ||
> let f = F.concat dt | ||
> return$ b :/ File "ALL_TEXT" f | ||
. | ||
Open all the files in the current directory as lazy bytestrings, ignoring | ||
the base path in Anchored wrapper: | ||
. | ||
> import qualified Data.ByteString.Lazy as B | ||
> (_ :/ dTree) <- readDirectoryWith B.readFile "./" {- "" works too -} | ||
. | ||
category: Data, System | ||
license: BSD3 | ||
license-file: LICENSE | ||
copyright: (c) 2009, Brandon Simmons <brandon.m.simmons@gmail.com> | ||
author: Brandon Simmons | ||
maintainer: Brandon Simmons <brandon.m.simmons@gmail.com> | ||
cabal-version: >= 1.2.0 | ||
build-type: Simple | ||
tested-with: GHC ==6.8.2 | ||
extra-source-files: examples.hs | ||
|
||
|
||
library | ||
exposed-modules: System.Directory.Tree | ||
build-depends: base |