diff --git a/CHANGELOG b/CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+0.3.2
+  * Create file used as lock if it doesn't exist. Thanks to Joshua Baker.
+  * Allow locking on directories.
+
 0.3.1.8
   * Allow monad-control 1.0.*.
 
diff --git a/System/Lock/FLock.hsc b/System/Lock/FLock.hsc
--- a/System/Lock/FLock.hsc
+++ b/System/Lock/FLock.hsc
@@ -31,6 +31,7 @@
                                    , dup
                                    )
 import System.Posix.Types          ( Fd(Fd) )
+import System.Posix.Files          ( stdFileMode )
 
 #include <sys/file.h>
 
@@ -48,6 +49,7 @@
 
 newtype Lock = Lock CInt
 
+-- | If no file or directory exists at the given path, a file will be created first.
 withLock :: (MonadIO m, MonadBaseControl IO m) => FilePath -> SharedExclusive -> Block -> m a -> m a
 withLock fp se b x =
   bracket
@@ -72,15 +74,12 @@
            Shared    -> c_LOCK_SH
            Exclusive -> c_LOCK_EX
 
+-- | If no file or directory exists at the given path, a file will be created first.
 lock :: MonadIO m => FilePath -> SharedExclusive -> Block -> m Lock
 lock fp se b = liftIO $
-  do Fd fd <- openFd fp om Nothing defaultFileFlags
+  do Fd fd <- openFd fp ReadOnly (Just stdFileMode) defaultFileFlags
      throwErrnoPathIfMinus1Retry_ "flock" fp $ flock fd (operation se b)
      return (Lock fd)
-  where
-    om = case se of
-           Shared    -> ReadOnly
-           Exclusive -> WriteOnly
 
 lockFd :: MonadIO m => Fd -> SharedExclusive -> Block -> m Lock
 lockFd fd se b = liftIO $
diff --git a/flock.cabal b/flock.cabal
--- a/flock.cabal
+++ b/flock.cabal
@@ -1,5 +1,5 @@
 Name:               flock
-Version:            0.3.1.8
+Version:            0.3.2
 License:            OtherLicense
 License-File:       COPYING
 Copyright:          Ian Lynagh, 2007
@@ -12,8 +12,8 @@
 Category:           System
 Homepage:           http://github.com/hesselink/flock
 Build-Type:         Simple
-Tested-With:        GHC==7.0.4, GHC==7.4.1, GHC==7.6.1
-Cabal-Version:      >= 1.6
+Tested-With:        GHC==7.4.1, GHC==7.6.3, GHC==7.8.3, GHC==7.10.2, GHC==8.0.2, GHC==8.2.1
+Cabal-Version:      >= 1.10
 Extra-source-files: "BSD3", "GPL-2", "CHANGELOG"
 
 Source-repository head
@@ -21,10 +21,11 @@
   Location:         git://github.com/hesselink/flock.git
 
 Library
-  Build-Depends:      base > 3 && < 5
-                    , transformers >= 0.2 && < 0.5
+  Build-Depends:      base > 3 && < 4.15
+                    , transformers >= 0.2 && < 0.6
                     , monad-control >= 0.3 && < 1.1
                     , lifted-base >= 0.1 && < 0.3
-                    , unix >= 2.3 && < 2.8
+                    , unix >= 2.5 && < 2.8
   Exposed-modules:    System.Lock.FLock
   GHC-Options:        -Wall
+  Default-Language:   Haskell2010
