Jap*_*tar 5 ruby unix windows zip
这是一个奇怪的问题。我有一个持续集成服务器(Windows 7)来构建 Unity 游戏。我正在构建的平台之一是 Linux,它与 Windows 构建过程类似,为该平台创建一个可执行文件和一个数据文件夹。一旦我压缩这些文件,然后在 Linux 上解压它,可执行文件就不会被标记为执行。在 Windows 中是否可以将此文件(且仅此文件的)权限设置为可执行文件(例如chmod +x filename),如果可以,我该如何实现这一点?
如果涉及脚本,我不介意它使用哪种语言,但我确实更喜欢 Ruby,因为我用它来自动压缩这些文件。这是我到目前为止所拥有的:
# Import modules
require 'zip'
# Define constants
PLATFORM_STRINGS = [' (Windows 32-bit)', \
' (Windows 64-bit)', \
' (Mac 32-bit)', \
' (Mac 64-bit)', \
' (Linux 32-bit)', \
' (Linux 64-bit)', \
' (Web)']
# Change directory
Dir.chdir(ARGV[0])
def get_application_name(directory)
for platform in PLATFORM_STRINGS
if directory.end_with?(platform)
return directory.sub(platform, '')
end
end
end
# Find all directories in this folder
for directory in Dir['*']
# Check if file is a directory
if File.directory?(directory)
# Retrieve the application name for this directory
application_name = get_application_name(directory)
zip_file_name = "#{directory}.zip"
# Create a zip file
Zip::File.open(zip_file_name, Zip::File::CREATE) do |zipfile|
# Traverse recursively through all files
Dir[File.join(directory, '**', '**')].each do |file|
# Replace the top-level directory name with the application's name
zipfile.add(file.sub(directory, application_name), file)
end
end
# Indicate the zip file that was created
puts "> Created: " + zip_file_name
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1107 次 |
| 最近记录: |