project_files/hwc/rtl/tests/fileio_test.c
author nemo
Fri, 17 Aug 2018 22:23:19 -0400
changeset 13669 c6ee1b0b957f
parent 10015 4feced261c68
permissions -rw-r--r--
more wrapping
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     1
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     2
#include "pas2c.h"
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     3
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     4
#include "fpcrtl.h"
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     5
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     6
char Pathz[1][128] = {"./"};
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     7
int ptCurrTheme = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     8
cThemeCFGFilename = "theme.cfg";
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     9
const string255 __str79 = STRINIT("object");
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    10
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    11
typedef struct __TResourceList {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    12
            Integer count;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    13
            string255 files[500 + 1];
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    14
} TResourceList;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    15
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    16
TResourceList readThemeCfg_0()
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    17
{
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    18
    TResourceList readthemecfg_result;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    19
    string255 s;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    20
    string255 key;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    21
    TextFile f;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    22
    Integer i;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    23
    TResourceList result;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    24
    s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    25
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    26
    assign(f, s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    27
    FileMode = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    28
    reset(f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    29
    result.count = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    30
    while(!eof(f))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    31
    {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    32
        readLnS(f, s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    33
        if((Length(s)) == (0))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    34
        {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    35
            continue;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    36
        }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    37
        if((s.s[1]) == ('\x3b'))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    38
        {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    39
            continue;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    40
        }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    41
        i = pos('\x3d', s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    42
        key = trim(copy(s, 1, i - 1));
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    43
        delete(s, 1, i);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    44
        if(_strcompare(key, __str79))
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    45
        {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    46
            i = pos('\x2c', s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    47
            result.files[result.count] = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), trim(copy(s, 1, i - 1)));
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    48
            ++result.count;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    49
        }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    50
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    51
    close(f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    52
    readthemecfg_result = result;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    53
    return readthemecfg_result;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    54
};
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    55
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    56
int main(int argc, char** argv)
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    57
{
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 7983
diff changeset
    58
    readThemeCfg_0();
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    59
}