.\
cgsourcedir.pro
top cgSourceDir
Utilities
result = cgSourceDir( [/NoMark] [, /OneUp] [, /TwoUp])
The purpose of this function is to provide a portable way of finding the source directory of a program distribution. The directory that is returned is the directory in which the source file using cgSourceDir() resides. The program is useful for distributing applications that have a large number of files in specific program directories (e.g., source, resources, data, etc.).
Keywords
- NoMark in optional type=boolean default=0
Normally, the source directory name is returned with a final path separator added to the end of the directory name. Setting this keyword will suppress this final path separator.
- OneUp in optional type=boolean default=0
Setting this keyword will return the directory just above the source directory in the file hierarchy.
- TwoUp in optional type=boolean default=0
Setting this keyword will return the directory two directories above the source directory in the file hierarchy.
Examples
Assume that your application files (and source programs) reside in this root directory:
../app
../app ; Contains your application and source (*.pro) files.
../app/data ; Contains your application data files.
...app/data/resources ; Contains your application resource files.
; Get icon image in resources directory.
filename = Filepath(Root_Dir=cgSourceDir(), Subdirectory=['data','resources'], 'myicon.tif')
; Get default image in data directory.
filename = Filepath(Root_Dir=cgSourceDir(), Subdirectory='data', 'ctscan.tif')
../app ; Contains your application files.
../app/source ; Contains your application source (*.pro) files.
../app/data ; Contains your application data files.
...app/data/resources ; Contains your application resource files.
; Get icon image in resources directory.
filename = Filepath(Root_Dir=cgSourceDir(/ONEUP), Subdirectory=['data','resources'], 'myicon.tif')
; Get default image in data directory.
filename = Filepath(Root_Dir=cgSourceDir(/ONEUP), Subdirectory='data', 'ctscan.tif')
Author information
- Author:
FANNING SOFTWARE CONSULTING:
David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com
- Copyright:
Copyright (c) 2003-2014, Fanning Software Consulting, Inc.
- History:
Change History:
Written by: David W. Fanning, 23 November 2003. Based on program SOURCEROOT, written by Jim Pendleton at RSI (http://www.rsinc.com/codebank/search.asp?FID=35). Added ONEUP keyword. 10 December 2003. DWF. Added TWOUP keyword. 8 June 2007. DWF. Added NOMARK keyword. 8 June 2007. DWF. Renamed from ProgramRootDir and updated to cgSourceDir. 27 Jan 2014. DWF.
File attributes
Modification date: | Fri Mar 27 11:07:37 2015 |
Lines: | 189 |
Docformat: | rst rst |