Skip to content

Commit 7b4368a

Browse files
author
Zachary Norman
committed
Added new file validator, updated README and LICENSE
1 parent 0a188fb commit 7b4368a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
(c) 2018 Harris Geospatial Solutions, Inc.
3+
Copyright (c) 2018 Harris Geospatial Solutions, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Routine that can be used to perform input validation for any routine to ensure t
88

99
- number : If set, value supplied must be a number.
1010

11+
- file : If set, the value must represent a valid file on disk.
12+
1113
This routine uses IDL's `isa` function to make the comparison so, in addition to the types above, you can specify anything else that can pass as an argument to the `isa` routine. Some additional examples of types are are: byte, int, long, float, hash, orderedhash, enviraster, graphicswin. The addition arguments can be any IDL-specific data type or it can also be the type of object such as idlgrwindow or any named, custom object.
1214

1315
## Examples
@@ -36,6 +38,6 @@ inputValidator, hash('nameOfArg', ['double', 'array'])
3638

3739
## License
3840

39-
(c) 2018 Harris Geospatial Solutions, Inc.
41+
Copyright (c) 2018 Harris Geospatial Solutions, Inc.
4042

4143
Licensed under MIT, see LICENSE.txt for more details.

inputvalidator.pro

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
; an existing variable from something like a hash so you can print the term
7272
; "Key" which is the correct term.
7373
;
74-
; :Author: Zachary Norman - GitHub : znorman-harris
74+
; :Author: Zachary Norman - GitHub : [znorman-harris](https://github.com/znorman-harris)
7575
;-
7676
pro inputValidator, requirements,$
7777
CALLED_FROM = called_from,$
@@ -132,6 +132,7 @@ pro inputValidator, requirements,$
132132
required = 0
133133
array = 0
134134
number = 0
135+
file = 0
135136

136137
;flag for if we need all data types specified to be present
137138
;otherwise just need one
@@ -156,6 +157,7 @@ pro inputValidator, requirements,$
156157
'required' : required = 1
157158
'array' : array = 1
158159
'number' : number = 1
160+
'file' : file = 1
159161
'all' : all = 1
160162

161163
else:begin
@@ -197,6 +199,13 @@ pro inputValidator, requirements,$
197199
endif
198200
endif
199201

202+
;check for file
203+
if (file) then begin
204+
if ~file_test(value) then begin
205+
message, pName + ' "' + varPrint + '" is not a file on disk, required!', LEVEL = scopeLevel
206+
endif
207+
endif
208+
200209
;check for number
201210
if (number) then begin
202211
nflag = isa(value, /NUMBER)

0 commit comments

Comments
 (0)