Valik Posted June 17, 2004 Share Posted June 17, 2004 Here are implementations of the C library functions splitpath, makepath and fullpath written in AutoIt. _SplitPath: Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing. _MakePath: Creates a path from drive, directory, file name and file extension parts. _FullPath: Creates a path based on the relative path you provide.The code is commented and the parameters are explained in the source. Get it at this http://www.autoitscript.com/fileman/users/Valik/path.au3 Link to comment Share on other sites More sharing options...
graham Posted June 24, 2004 Share Posted June 24, 2004 (edited) here are a few extras, since I like to have procedure calls to get the various parts on their own & use them to construct strings, plus one fn() to change a files extansion - useful for naming log files/backup files, etc Btw, is there a web site anywhere which lists all fn()s & scraps which are available? ;=============================================================================== ; ; Description: Given a fully qualified path name (such as one returned ; from _MakePath(), will return the volume part. ; Syntax: _GetVolumeFromFullPath( $fullPath ) ; Parameter(s): $fullPath - fully qualified path name ; Requirement(s): None ; Return Value(s): volume part of given path ; Author(s): Graham Keellings software@Keellings.com ; Note(s): None ; ;=============================================================================== Func _GetVolumeFromFullPath( $fullPath ) Local $szDrive, $szDir, $szFName, $szExt _SplitPath($fullPath, $szDrive, $szDir, $szFName, $szExt) return $szDrive EndFunc ;=============================================================================== ; ; Description: Given a fully qualified path name (such as one returned ; from _MakePath(), will return the directory part. ; Syntax: _GetDirectoryFromFullPath( $fullPath ) ; Parameter(s): $fullPath - fully qualified path name ; Requirement(s): None ; Return Value(s): directory part of given path ; Author(s): Graham Keellings software@Keellings.com ; Note(s): None ; ;=============================================================================== Func _GetDirectoryFromFullPath( $fullPath ) Local $szDrive, $szDir, $szFName, $szExt _SplitPath($fullPath, $szDrive, $szDir, $szFName, $szExt) return $szDir EndFunc ;=============================================================================== ; ; Description: Given a fully qualified path name (such as one returned ; from _MakePath(), will return the file name part. ; Syntax: _GetFileNameFromFullPath( $fullPath ) ; Parameter(s): $fullPath - fully qualified path name ; Requirement(s): None ; Return Value(s): file name part of given path ; Author(s): Graham Keellings software@Keellings.com ; Note(s): None ; ;=============================================================================== Func _GetFileNameFromFullPath( $fullPath ) Local $szDrive, $szDir, $szFName, $szExt _SplitPath($fullPath, $szDrive, $szDir, $szFName, $szExt) return $szFName EndFunc ;=============================================================================== ; ; Description: Given a fully qualified path name (such as one returned ; from _MakePath(), will return the extension part. ; Syntax: _GetExtensionFromFullPath( $fullPath ) ; Parameter(s): $fullPath - fully qualified path name ; Requirement(s): None ; Return Value(s): extension part of given path ; Author(s): Graham Keellings software@Keellings.com ; Note(s): None ; ;=============================================================================== Func _GetExtensionFromFullPath( $fullPath ) Local $szDrive, $szDir, $szFName, $szExt _SplitPath($fullPath, $szDrive, $szDir, $szFName, $szExt) return $szExt EndFunc ;=============================================================================== ; ; Description: Given a fully qualified path name (such as one returned ; from _MakePath(), will change the extension part as requested. ; Syntax: _ChangeFileExtension( $fullPath ) ; Parameter(s): $fullPath - fully qualified path name ; $newExtension - nex extension ; Requirement(s): None ; Return Value(s): fully qualified path name with new extension ; Author(s): Graham Keellings software@Keellings.com ; Note(s): Useful for naming log files, backup files & otehr output files. ; ;=============================================================================== Func _ChangeFileExtension( $fullPath, $newExtension ) Local $szDrive, $szDir, $szFName, $szExt _SplitPath($fullPath, $szDrive, $szDir, $szFName, $szExt) return _MakePath($szPath, $szDrive, $szDir, $szFName, $newExtension) EndFunc Edited June 24, 2004 by graham Link to comment Share on other sites More sharing options...
emmanuel Posted June 25, 2004 Share Posted June 25, 2004 very cool Valik, what do you think of having it check for and resolve UNC's? "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted June 25, 2004 Share Posted June 25, 2004 Btw, is there a web site anywhere which lists all fn()s & scraps which are available?that'd be pretty swank, a db of UDF's searchable on what it does, or what catagory it falls under... Anyone know if there's already server software for doing that? "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Valik Posted June 25, 2004 Author Share Posted June 25, 2004 very cool Valik, what do you think of having it check for and resolve UNC's?Well, these functions don't stipulate that the path actually exist, only that it is or can be made into a valid path with the information provided. I stepped beyond the C versions of these functions when I made them compatible with UNC paths, but that's as far as I am taking them. The only validation of anything that could be added would be to ensure there are no illegal characters in the path (such as <>?*", et cetera). However, even the C versions don't support that, though, so I didn't, either. The first draft mimicked the C versions identically; I think it was requested UNC paths work so I added it. Otherwise, these functions are meant to be completely decoupled from the real filesystem in regards to existence/non-existence of one or more parts of the path. Link to comment Share on other sites More sharing options...
emmanuel Posted June 25, 2004 Share Posted June 25, 2004 Well, these functions don't stipulate that the path actually exist, only that it is or can be made into a valid path with the information provided. I stepped beyond the C versions of these functions when I made them compatible with UNC paths, but that's as far as I am taking them. The only validation of anything that could be added would be to ensure there are no illegal characters in the path (such as <>?*", et cetera). However, even the C versions don't support that, though, so I didn't, either. The first draft mimicked the C versions identically; I think it was requested UNC paths work so I added it. Otherwise, these functions are meant to be completely decoupled from the real filesystem in regards to existence/non-existence of one or more parts of the path.ooohhh... they do support UNC... awesome, (this is me, blind) I wasn't meaning that they should check the path's validity (or that a server was up, etc) you already did it. awesome. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
odklizec Posted July 17, 2005 Share Posted July 17, 2005 The link to path.au3 seems to be dead. Does anyone know where I can get this file? Link to comment Share on other sites More sharing options...
Developers Jos Posted July 17, 2005 Developers Share Posted July 17, 2005 The link to path.au3 seems to be dead. Does anyone know where I can get this file?<{POST_SNAPBACK}>These UDFs are part of the File.au3 standard UDF lib.Their names are now _PathFull,_PathMake,_PathSplit .. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
odklizec Posted July 17, 2005 Share Posted July 17, 2005 These UDFs are part of the File.au3 standard UDF lib.Their names are now _PathFull,_PathMake,_PathSplit ..<{POST_SNAPBACK}>Ups..this must be my old AutoIt. I've not used it in a long time and therefore I don't have the latest version Thanks for info! Link to comment Share on other sites More sharing options...
GaryFrost Posted July 17, 2005 Share Posted July 17, 2005 It's only in the beta UDFs SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 17, 2005 Developers Share Posted July 17, 2005 You can find the current UDF files here ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
odklizec Posted July 17, 2005 Share Posted July 17, 2005 Thanks! I found it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now