请选择 进入手机版 | 继续访问电脑版

潇潇编程综合教学网

 找回密码
 注册
Flash解密FRC(Flash Resource Catcher)注册会员邮箱认证须知!
查看: 978|回复: 2

【叶子出品】FreeBasic 根据文件路径获取 目录、文件名、后缀

[复制链接]
叶子的离开 发表于 2015-8-30 14:40:52 | 显示全部楼层 |阅读模式
本代码采用 crt 实现,为什么呢?因为FB的标准库太坑了,除了混乱的类型以外,也会明显增量程序,并且性能很差。

上代码~

[Visual Basic] 纯文本查看 复制代码
Function GetPathFloder(sInPath As ZString Ptr, sOutPath As ZString Ptr) As Integer
	Dim rstr As ZString Ptr = StrRChr(sInPath, 92)
	If rstr Then
		memcpy(sOutPath, sInPath, rstr - sInPath)
		Return -1
	EndIf
End Function

Function GetPathFileName(sInPath As ZString Ptr, sOutPath As ZString Ptr) As Integer
	Dim rstr As ZString Ptr = StrRChr(sInPath, 92)
	If rstr Then
		strcpy(sOutPath, rstr + 1)
		Return -1
	EndIf
End Function

Function GetFileFileType(sInPath As ZString Ptr, sOutPath As ZString Ptr) As Integer
	Dim rstr As UByte Ptr = StrRChr(sInPath, 46)
	If rstr Then
		For i As Integer = 1 To strlen(rstr)
			sOutPath[i-1] = toupper(rstr[i])
		Next
		Return -1
	EndIf
End Function

Function GetPathFileType(sInPath As ZString Ptr, sOutPath As ZString Ptr) As Integer
	Dim TmpPath As ZString Ptr = malloc(MAX_PATH)
	If GetPathFileName(sInPath, TmpPath) Then
		If GetFileFileType(TmpPath, sOutPath) Then
			free(TmpPath)
			Return -1
		EndIf
	EndIf
	free(TmpPath)
End Function
 楼主| 叶子的离开 发表于 2015-9-6 10:19:36 | 显示全部楼层

c runtime。
对于windows来说,一般指 msvcrt.dll
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|潇潇编程综合教学网 ( 滇ICP备09007156号-2 )

滇公网安备 53050202000040号

GMT+8, 2018-1-20 18:45 , Processed in 0.185014 second(s), 20 queries .

Powered by Discuz!

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表