A Utilitarian F# Library

I started building an F# library that could be used to hold housekeeping routines. This is the start of that library.

namespace Toa.volLib
open System
open System.Threading
open System.Collections.Generic
open System.Text
open System.IO
open Microsoft.Win32

type DiskFreeLevels =
  | GB1   = 1000000000L
  | GB5   = 5000000000L
  | GB10  = 10000000000L

module volLib =
  let libInit = ref false

  let driveList () =

  let freeSpace drive =
    let di = DriveInfo(drive)

  if di.IsReady then int64(di.AvailableFreeSpace)
  else int64(DiskFreeLevels.GB10)

  let cvtBytesToGB (inBytes:int64) =
    truncate((float(int64(inBytes)) / float(1024L) / float(1024L)) / float(1024L))

  let GB1     = cvtBytesToGB(int64(DiskFreeLevels.GB1))
  let GB5     = cvtBytesToGB(int64(DiskFreeLevels.GB5))
  let GB10    = cvtBytesToGB(int64(DiskFreeLevels.GB10))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s