EnglishРусский  

   ..

   fileattrib.1.g

The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

source\samples\fileattrib\fileattrib.1.g
 1 /******************************************************************************
 2 *
 3 * Copyright (C) 2005, The Gentee Group. All rights reserved. 
 4 * This file is part of the Gentee open source project - http://www.gentee.com. 
 5 * 
 6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
 7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
 8 * ACCEPTANCE OF THE AGREEMENT.
 9 *
10 * ID: fileattrib 17.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15 
16 func main< main >
17 {
18    uint  mode attrib
19    str   temp
20    str   path
21    ffind fd
22       
23    if argc() > 1
24    {
25       if argv( temp, 1 ) %== "on" : mode = 1
26       elif argv( temp, 1 ) %== "off" : mode = 2
27       argv( path, 2 )
28    }
29    if !mode
30    {
31       mode = conrequest( "Choose an action (press a number key):
32 1. Turn on readonly attribute
33 2. Turn off readonly attribute
34 3. Exit\n", "1|2|3" ) + 1
35 
36       if mode == 3 : return      
37 
38       congetstr( "Specify a filename or a wildcard: ", path )
39    }
40    print( "Action: turn \(?(mode == 1, "ON", "OFF")) readonly attribute\n" )
41    fd.init( path, $FIND_FILE | $FIND_RECURSE )
42    foreach cur,fd
43    {
44       attrib = getfileattrib( cur.fullname )
45       if mode == 1 : attrib |= $FILE_ATTRIBUTE_READONLY
46       else : attrib &= ~$FILE_ATTRIBUTE_READONLY
47       setfileattrib( cur.fullname, attrib )
48       print( "\(cur.fullname)\n" )
49    }
50    congetch( "Press any key..." )
51 }
52