1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-19 09:43:14 +00:00

convmv command WIP

This commit is contained in:
nielash
2024-02-06 10:11:46 -05:00
committed by Nick Craig-Wood
parent ccef29bbff
commit d08543070a
6 changed files with 1091 additions and 27 deletions

View File

@@ -151,8 +151,8 @@ func init() {
alias("Dot", EncodeDot)
}
// validStrings returns all the valid MultiEncoder strings
func validStrings() string {
// ValidStrings returns all the valid MultiEncoder strings
func ValidStrings() string {
var out []string
for k := range nameToEncoding {
out = append(out, k)
@@ -192,7 +192,7 @@ func (mask *MultiEncoder) Set(in string) error {
} else {
i, err := strconv.ParseUint(part, 0, 0)
if err != nil {
return fmt.Errorf("bad encoding %q: possible values are: %s", part, validStrings())
return fmt.Errorf("bad encoding %q: possible values are: %s", part, ValidStrings())
}
out |= MultiEncoder(i)
}
@@ -313,8 +313,7 @@ func (mask MultiEncoder) Encode(in string) string {
}
if mask.Has(EncodeAsterisk) { // *
switch r {
case '*',
'':
case '*', '':
return true
}
}
@@ -346,64 +345,55 @@ func (mask MultiEncoder) Encode(in string) string {
}
if mask.Has(EncodeQuestion) { // ?
switch r {
case '?',
'':
case '?', '':
return true
}
}
if mask.Has(EncodeColon) { // :
switch r {
case ':',
'':
case ':', '':
return true
}
}
if mask.Has(EncodePipe) { // |
switch r {
case '|',
'':
case '|', '':
return true
}
}
if mask.Has(EncodeDoubleQuote) { // "
switch r {
case '"',
'':
case '"', '':
return true
}
}
if mask.Has(EncodeSingleQuote) { // '
switch r {
case '\'',
'':
case '\'', '':
return true
}
}
if mask.Has(EncodeBackQuote) { // `
switch r {
case '`',
'':
case '`', '':
return true
}
}
if mask.Has(EncodeDollar) { // $
switch r {
case '$',
'':
case '$', '':
return true
}
}
if mask.Has(EncodeSlash) { // /
switch r {
case '/',
'':
case '/', '':
return true
}
}
if mask.Has(EncodeBackSlash) { // \
switch r {
case '\\',
'':
case '\\', '':
return true
}
}
@@ -416,15 +406,13 @@ func (mask MultiEncoder) Encode(in string) string {
}
if mask.Has(EncodeHash) { // #
switch r {
case '#',
'':
case '#', '':
return true
}
}
if mask.Has(EncodePercent) { // %
switch r {
case '%',
'':
case '%', '':
return true
}
}
@@ -1182,6 +1170,7 @@ func appendQuotedBytes(w io.Writer, s string) {
_, _ = fmt.Fprintf(w, string(QuoteRune)+"%02X", b)
}
}
func appendUnquotedByte(w io.Writer, s string) bool {
if len(s) < 2 {
return false
@@ -1202,12 +1191,15 @@ func (identity) Decode(in string) string { return in }
func (i identity) FromStandardPath(s string) string {
return FromStandardPath(i, s)
}
func (i identity) FromStandardName(s string) string {
return FromStandardName(i, s)
}
func (i identity) ToStandardPath(s string) string {
return ToStandardPath(i, s)
}
func (i identity) ToStandardName(s string) string {
return ToStandardName(i, s)
}