...
 
Commits (3)
......@@ -84,6 +84,8 @@ let toMingwPath (windowsPath: string) =
result
// Convert Mingw64 path to windows path.
// supported mingwPath format: /cygdrive/x/xxx
// return null if given path is not in this format.
let toWinPath (mingwPath: string) =
if mingwPath.StartsWith("/cygdrive/") then
let driveLetter = mingwPath.Substring("/cygdrive/".Length, 1).ToUpper()
......
This diff is collapsed.
......@@ -61,7 +61,8 @@ Here are the backup list files and exclude pattern files:
local-list.txt and local-exclude.txt are managed by user. mbackup will not
modify those files when it is uninstalled or upgraded. The other lists are
shipped with mbackup and will be removed/overwritten when
uninstalling/upgrading mbackup.
uninstalling/upgrading mbackup. All text files should be in utf-8 encoding,
especially if they include unicode file path.
To learn more about file list and exclude patterns, read rsync man page
https://download.samba.org/pub/rsync/rsync.html --files-from option,
......
module Mbackup.TypedFilePath
open System
open System.IO
// use Discriminated Unions to represent windows path and mingw style linux path.
type TypedFilePath =
| WinPath of path: string
| MingwPath of path: string
| PortablePath of path: string
let joinPath (part1: TypedFilePath) (part2: TypedFilePath) =
match part1 with
| WinPath(p1) ->
match part2 with
| WinPath(p2) | PortablePath(p2) ->
WinPath(Lib.ensureWinDir(p1) + p2)
| _ ->
failwith "Coding error. trying to join different Path type"
| MingwPath(p1) ->
match part2 with
| MingwPath(p2) | PortablePath(p2) ->
MingwPath(Lib.ensureDir(p1) + p2)
| _ ->
failwith "Coding error. trying to join different Path type"
| _ ->
failwith "Coding error. joinPath first path should not be PortablePath"
let joinPortablePath (part1: TypedFilePath) (part2: string) =
joinPath part1 (PortablePath part2)
let toString (tpath: TypedFilePath) =
match tpath with
| WinPath(path) | MingwPath(path) | PortablePath(path) -> path
let toWinPath (tpath: TypedFilePath): string =
match tpath with
| WinPath(path) | PortablePath(path) -> path
| MingwPath(path) -> Lib.toWinPath(path)
let toWin (tpath: TypedFilePath): TypedFilePath =
match tpath with
| MingwPath(path) -> WinPath(Lib.toWinPath(path))
| x -> x
let toMingwPath (tpath: TypedFilePath): string =
match tpath with
| WinPath(path) | PortablePath(path) -> Lib.toMingwPath(path)
| MingwPath(path) -> path
let toMingw (tpath: TypedFilePath): TypedFilePath =
match tpath with
| WinPath(path) -> MingwPath(Lib.toMingwPath(path))
| x -> x
let ensureDir (tpath: TypedFilePath) =
match tpath with
| WinPath(path) -> WinPath(if path.EndsWith "\\" then path else path + "\\")
| MingwPath(path) -> MingwPath(if path.EndsWith "/" then path else path + "/")
| PortablePath(path) -> failwith "Coding error. ensureDir should not be called on PortablePath"
# files/dirs to exclude, for syntax, check rsync patterns
# This file is reserved when uninstall/upgrade mbackup.
# lines started with # are comments.
# unicode characters in path is supported such as D:\Movies\疯狂的赛车\***
# example:
# *.o
# C:\foo\bar.iso
# local dirs to backup.
# This file is reserved when uninstall/upgrade mbackup.
# lines started with # are comments.
# unicode characters in path is supported such as D:\Movies\疯狂的赛车
# example:
# C:\mydir
# D:\some dir\some file.doc
......@@ -23,12 +23,13 @@
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<RootNamespace>Mbackup</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>0.6.1.0</Version>
<Version>0.6.3.0</Version>
</PropertyGroup>
<ItemGroup>
<Compile Include="Lib.fs" />
<Compile Include="ConfigParser.fs" />
<Compile Include="TypedFilePath.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
......
* COMMENT -*- mode: org -*-
#+Date: 2019-11-12
Time-stamp: <2019-11-18>
Time-stamp: <2019-11-30>
#+STARTUP: content
* notes :entry:
** 2019-11-12 mbackup for windows :featurereq:
......@@ -245,6 +245,18 @@ vscode should at least always indent using space for F#.
* current :entry:
**
** 2019-11-30 support itemize-changes option in config file.
itemize-changes=yes
itemize-changes=no
-i --itemize-changes
** 2019-11-30 support default-docs=no option.
both in command line arguments and in config file.
--default-docs
--no-default-docs
** 2019-11-24 Make sure Chinese file name works in local.list file.
** 2019-11-23 when default .ssh dir is in %programdata%\mbackup\.ssh,
there is a security concern.
......@@ -284,6 +296,25 @@ Are there any code change required?
** 2019-11-18 add log rotate for %localappdata%\mbackup\mbackup.log
* done :entry:
** 2019-11-30 bug: mbackup local exclude config is not used in rsync command.
L271 should use win path when check whether file exists.
- can I use typing to specify when a Linux path is required and when a windows
path is required?
Introduction to functional data types in F#
https://markvincze.github.io/fsharp-datatypes-intro/#/13
Discriminated Unions - F# | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/discriminated-unions
- fixed in v0.6.3.0
** 2019-11-30 shipped local list, local exclude file should be in utf-8 encoding.
when user open the file using notepad, it should be in utf-8 encoding.
just add some unicode character in shipped local list file and save in utf-8 encoding
in windows.
** 2019-11-19 allow local Users group to have full access to local list and local exclude file.
by default, only admin can modify them, Users can only read/execute them.
......