【GameMaker】分离文件路径、文件名、后缀-创新互联

对于Windows和MacOS的构建目标,YoYoGames官方提供了一系列用于获取文件路径的函数。

10余年的天祝藏族自治网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整天祝藏族自治建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“天祝藏族自治网站设计”,“天祝藏族自治网站推广”以来,每个客户项目都认真落实执行。
  • get_open_filename
  • get_open_filename_ext
  • get_save_filename
  • get_save_filename_ext

但本文并不叙述如何获取路径,我们假设如果你已经有了一串路径。

theFilePath = "C:\Program Files\GameMaker\GameMaker.exe"

我们一般可以进行以下操作——

分离文件路径与文件名
function SplitPath(FilePath){
	var Pos = string_last_pos("/",FilePath) //检测最后一个/的位置
	if(string_last_pos("\\",FilePath) >Pos){
		 Pos = string_last_pos("\\",FilePath) //检测最后一个\的位置
	}
	return [string_copy(FilePath,1,Pos),string_copy(FilePath,Pos+1,string_length(FilePath))]
}

var theFilePath = "C:/Program Files/GameMaker/GameMaker.exe"

filepath = SplitPath(theFilePath)

// In: show_debug_message(filepath[0])
// Out: C:/Program Files/GameMaker/
// In: show_debug_message(filepath[1])
// Out: GameMaker.exe

其中filepath为所求数组,其中包含了两个值:文件夹路径,文件名。

分离文件名与后缀
function SplitFileName(FileName){
	var Pos = string_last_pos(".",FileName) //检测最后一个.的位置
	return [string_copy(FileName,1,Pos-1),string_copy(FileName,Pos,string_length(FileName))]
}

var theFileName = "GameMaker.exe"

filenamed = SplitFileName(theFileName)

// In: show_debug_message(filenamed[0])
// Out: GameMaker
// In: show_debug_message(filenamed[1])
// Out: .exe

其中filenamed为所求数组,其中包含了两个值:文件名,后缀名。

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


文章题目:【GameMaker】分离文件路径、文件名、后缀-创新互联
文章源于:http://myzitong.com/article/dsippc.html