gpt4 book ai didi

尝试添加 Mac 自定义图标文件时,svn 在路径 "Invalid control character ' 中返回 'Icon\015' 0x0d'

转载 作者:行者123 更新时间:2023-12-04 21:05:17 27 4
gpt4 key购买 nike

我有一个创建磁盘镜像的项目,并希望为加载的卷使用自定义图标。我有一个 .VolumeIcon.icns文件看起来不错,但为了让 Finder 使用它,我必须包含一个名为 Icon^M 的空文件。 (图标\r,图标 )。我的自定义图标出现了,一切正常。

除了。当我尝试将 Icon^M 文件 checkin 我的 svn 存储库时,我得到:

svn: Invalid control character '0x0d' in path 'Icon\015'

Subversion 具有比 Mac 更严格的文件名标准,并且合理地不允许回车。 svn 邮件列表上的一个旧线程讨论了这个问题,建议只使用 shell 脚本创建文件作为构建过程的一部分。我可以这样做,但我的构建过程现在非常简单,我不愿意让它变得更复杂。

有没有更优雅的解决方案?

最佳答案

图标的这个问题困扰了我一段时间。基本的解决方案基本上是完全忽略该文件,我拒绝这样做,因为我是一个视觉人士,并且喜欢浪费时间为我的项目创建很酷的图标。

注意:我已尽力确保它有效,但我不能保证它,因此请尝试复制您的数据。话虽如此,这是我对这个问题的解决方案。

基本上我创建了 3 个脚本来解决 mac 图标\r 问题。

  • repoMacPrepare.sh
  • repoMacRestore.sh
  • gitAliasScript.sh

  • 这三个脚本是用来添加 git 或 svn 可以接受和存储的格式的 mac 图标。第一个脚本准备存储库搜索目录中基于图标的文件和文件中的自定义图标格式。然后将它们存储为 .jdIcnd 或 .jdIcnf(d 表示目录 f 表示文件夹)在各自的路径中。

    第二个脚本允许它通过搜索 .jdIcnd 和 .jdIcnf 文件在 mac 上恢复生机。

    最后一个脚本显示了如何自动化该过程。我为 git 使用了一个别名,该别名在我的 .bashrc 文件中引用了 gitAliasScript.sh 脚本。现在我切换到 git(我做过的最好的事情)所以脚本是为 git 显示的,但基本原理在 svn 中是相同的。我希望这可以帮助使用版本控制系统的 mac 用户,他们不会在 checkin 过程或 checkout 过程中丢失他们的图标。另请注意,那些不使用此脚本的人不会有问题,因为图标存储为带有点前缀的二进制文件,使它们不可见。哦对...

    文件:repoMacPrepare.sh
    #! /bin/bash
    #
    # Author: Joshua Demori
    # Email: jdemori@jrdfamily.com
    #
    # This script is used to prepare a repository
    # to still record the Icons used on a mac for files or directories
    #
    # First
    # DeRez Icon^M > .IconCntrlR
    # (hit control-v then enter to get the carriage return vi)
    #
    # Store in Repository
    # then to bring back
    # Rez -append IconCopy -o Icon
    # # may need to set the Folders Icon Info
    # SetFile -a C /Path/To/Custom/Folder/With/Icon/
    #
    # if I need to SetFile the folder I can do this 2 ways
    # a main file which has all this data at base of repository (bad)
    # as it finds those files it does the folder below it
    #
    #

    #=======================================================#
    # Defines
    readonly VERSION=1.00

    #=======================================================#
    # Variables
    varVerbose=false

    #=======================================================#
    # Functions
    setupDirIcon () {
    DeRez "${file}"/Icon
    > "${file}"/.Icon.jdIcnd
    if [ $varVerbose == true ]; then
    echo Adding Icon File: "$file"/.Icon.jdIcnd
    fi
    }


    setupFileIcon () {
    base=`basename "$file"`
    path=`dirname "$file"`
    DeRez "$file" > "${path}"/."${base}".jdIcnf
    if [ $varVerbose == true ]; then
    echo Adding Icon File: "$file"/."${base}".jdIcnf
    fi
    }

    # cmd line functions
    function funcOptionVersion {
    echo "Reposiotry Mac Icon Preperation Script Version: $VERSION"
    exit 0
    }


    function funcOptionHelp {
    name=`basename $0`
    echo $name Help Screen
    echo '-h help'
    echo '-v verbose'
    echo '-n version'
    echo ' '
    exit 0
    }

    function funcOptionVerbose {
    varVerbose=true
    }


    #=======================================================#
    # process cmd line arguments
    while getopts "vhn" optionName; do
    case "$optionName" in
    n) funcOptionVersion ;;
    h) funcOptionHelp ;;
    v) funcOptionVerbose ;;
    [?]) printErrorHelpAndExit "$badOptionHelp";;
    esac
    done

    #=======================================================#
    #=======================================================#
    # Start main portion of script

    # ignore . .DS_Store .git folders and files
    find . | grep -v ^.$ | grep -v .DS_Store | grep -v .git | grep -v .svn | while read file
    do

    # does this file have an icon attribute
    GetFileInfo -a "$file" | grep C > /dev/null
    if [ $? = 0 ]; then
    if [ -d "$file" ]; then
    setupDirIcon
    else
    setupFileIcon
    fi
    fi # end if for icon test

    done

    # Remove Only the Icon file used by directories
    echo Removing Icon File

    if [ $varVerbose == true ]; then
    find . -name Icon
    -print -exec rm {} \;
    else
    find . -name Icon
    -exec rm {} \;
    fi

    文件:repoMacRestore.sh
    #! /bin/bash
    #
    # Author: Joshua Demori
    # Email: jdemori@jrdfamily.com
    #
    # This Script complemnts xxxx by reversing the icons as derez to rez
    # then setting the proper file attributes to view the icons
    #
    # First
    # DeRez Icon^M > .IconCntrlR
    # (hit control-v then enter to get the carriage return vi)
    #
    # Store in Repository
    # then to bring back
    # Rez -append IconCopy -o Icon
    # # may need to set the Folders Icon Info
    # SetFile -a C /Path/To/Custom/Folder/With/Icon/
    #
    # if I need to SetFile the folder I can do this 2 ways
    # a main file which has all this data at base of repository (bad)
    # as it finds those files it does the folder below it
    #
    #


    #=======================================================#
    # Defines
    readonly VERSION=1.00

    #=======================================================#
    # Variables
    varVerbose=false

    #=======================================================#
    # Functions
    # cmd line functions
    function funcOptionVersion {
    echo "Repository Mac Icon Restore Script Version: $VERSION"
    exit 0
    }


    function funcOptionHelp {
    name=`basename $0`
    echo $name Help Screen
    echo '-h help'
    echo '-v verbose'
    echo '-n version'
    echo ' '
    exit 0
    }

    function funcOptionVerbose {
    varVerbose=true
    }


    #=======================================================#
    # process cmd line arguments
    while getopts "vhn" optionName; do
    case "$optionName" in
    n) funcOptionVersion ;;
    h) funcOptionHelp ;;
    v) funcOptionVerbose ;;
    [?]) printErrorHelpAndExit "$badOptionHelp";;
    esac
    done


    #=======================================================#
    #=======================================================#
    # Start main portion of script


    #=======================================================#
    # Go thourgh directories
    find . -name *.jdIcnd | while read file
    do

    # is it a dir - restore dir icon
    echo "$file" | grep jdIcnd
    if [ $? = 0 ]; then
    if [ $varVerbose == true ]; then
    echo Fixing Directory Icon: "$file"
    fi
    path=`dirname "$file"`
    Rez "$file" -o "${path}"/Icon
    SetFile -a V "${path}"/Icon
    SetFile -a C "${path}"
    fi

    done

    # Go thourgh files
    # is it a file - restore file icon
    find . -name *.jdIcnf | while read file
    do
    echo "$file" | grep jdIcnf
    if [ $? = 0 ]; then
    path=`dirname "$file"`
    base=`basename "$file"`
    origFileName=`echo "$base" | sed 's/\.jdIcnf//'`
    origFileName=`echo "${origFileName:1}"`
    fileWithPath="${path}"/"${origFileName}"
    if [ $varVerbose == true ]; then
    echo Restoring File Icon: "$path"
    fi
    #echo origFileName: "$origFileName"
    #echo filesWithPath: "$fileWithPath"
    Rez -append "$file" -o "$fileWithPath"
    SetFile -a C "$fileWithPath"
    fi

    done

    gitAliasScript.sh
    #! /bin/bash

    found=false
    args=("$@")
    for var in "$@"
    do
    x=`echo $var | grep -ic commit`
    if [ $x == 1 ]; then
    # prepare icons to be saved
    # add them to repository
    # at the end git is run
    repoMacPrepare.sh
    find . -name *.jdIcnd -exec git add {} \;
    find . -name *.jdIcnf -exec git add {} \;
    found=true
    fi
    done

    #runs git cmd here
    cmdPart='git '
    cmd=${cmdPart}${@}
    $cmd

    # finish by bringing back icons
    # if commit was called
    if [ $found == true ]; then
    repoMacRestore.sh
    fi

    exit 0

    关于尝试添加 Mac 自定义图标文件时,svn 在路径 "Invalid control character ' 中返回 'Icon\015' 0x0d',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6297346/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com