gameServer/OfficialServer/GameReplayStore.hs
changeset 11341 e6e748d021d0
parent 11320 556eafd1443a
equal deleted inserted replaced
11340:dfcbc2639ade 11341:e6e748d021d0
    36 import EngineInteraction
    36 import EngineInteraction
    37 
    37 
    38 
    38 
    39 pickReplayFile :: Int -> [String] -> IO String
    39 pickReplayFile :: Int -> [String] -> IO String
    40 pickReplayFile p blackList = do
    40 pickReplayFile p blackList = do
    41     files <- liftM (filter (\f -> sameProto f && notBlacklisted f)) $ getDirectoryContents "replays"
    41     files <- liftM (filter (\f -> sameProto f && notBlacklisted ("replays/" ++ f))) $ getDirectoryContents "replays"
    42     if (not $ null files) then
    42     if (not $ null files) then
    43         return $ "replays/" ++ head files
    43         return $ "replays/" ++ head files
    44         else
    44         else
    45         return ""
    45         return ""
    46     where
    46     where
    47         sameProto = (isSuffixOf ('.' : show p))
    47         sameProto = isSuffixOf ('.' : show p)
    48         notBlacklisted = flip notElem blackList
    48         notBlacklisted = flip notElem blackList
    49 
    49 
    50 saveReplay :: RoomInfo -> IO ()
    50 saveReplay :: RoomInfo -> IO ()
    51 saveReplay r = do
    51 saveReplay r = do
    52     let gi = fromJust $ gameInfo r
    52     let gi = fromJust $ gameInfo r