/* --------------------------------------------------------------- */ /* Return 1 if file or directory exists, 0 otherwise */ /* --------------------------------------------------------------- */ /* Copyright (c) Mike Cowlishaw, 2010, 2013. All rights reserved. */ /* */ /* Permission to use, copy, modify, and/or distribute this */ /* software for any purpose with or without fee is hereby granted, */ /* provided that the above copyright notice and this permission */ /* notice appear in all copies, and that notice and the date of */ /* any modifications be added to the software. */ /* */ /* This software is provided "as is". No warranties, whether */ /* express, implied, or statutory, including, but not limited to, */ /* implied warranties of merchantability and fitness for a */ /* particular purpose apply to this software. The author shall */ /* not, in any circumstances, be liable for special, incidental, */ /* or consequential damages, for any reason whatsoever. */ /* */ /* --------------------------------------------------------------- */ /* */ /* Arg1 is fully qualified file or directory name to test */ /* */ /* A file of size 0 is deemed not to exist. */ /* Note this cannot be used to test for root directory. */ /* --------------------------------------------------------------- */ -- 'query exists' doesn't work for directories exists: parse arg spec call sysfiletree spec, 'LIST', 'BL' if list.0\=1 then return 0 -- does not exist parse var list.1 . . size flags . if size>0 then return 1 -- real file return substr(flags, 2, 1)='D' -- 1 if directory, 0 if zero-size file