project_files/hwc/rtl/sysutils.c
author nemo
Wed, 07 Sep 2022 16:49:59 -0400
branch1.0.0
changeset 15854 aefa91a7acf4
parent 14913 68e1783762bc
child 15877 6cb7330113d8
permissions -rw-r--r--
Added tag 1.0.1-release for changeset fcea0f51d94f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     1
#include "SysUtils.h"
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     2
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     3
#include <time.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     4
#include <stdio.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     5
#include <stdlib.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     6
#include <string.h>
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     7
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     8
#include "system.h"
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
     9
#include "misc.h"
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    10
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    11
TDateTime fpcrtl_date()
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    12
{
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    13
    const int num_days_between_1900_1980 = 29220;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    14
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    15
    struct tm ref_date;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    16
    struct tm cur_date;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    17
    time_t local_time;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    18
    time_t ref_time, cur_time;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    19
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    20
    double timeDiff;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    21
    double day_time_frac; //fraction that represents the time in one day
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    22
    int num_seconds;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    23
    int numDays;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    24
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    25
    // unix epoch doesn't work, choose Jan 1st 1980 instead
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    26
    ref_date.tm_year = 80;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    27
    ref_date.tm_mon = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    28
    ref_date.tm_mday = 1;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    29
    ref_date.tm_hour = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    30
    ref_date.tm_min = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    31
    ref_date.tm_sec = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    32
    ref_date.tm_isdst = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    33
    ref_date.tm_wday = 0; // ignored
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    34
    ref_date.tm_yday = 0; // ignored
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    35
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    36
    local_time = time(NULL);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    37
    cur_date = *localtime(&local_time);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    38
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    39
    cur_date.tm_hour = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    40
    cur_date.tm_min = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    41
    cur_date.tm_sec = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    42
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    43
    ref_time = mktime(&ref_date);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    44
    cur_time = mktime(&cur_date);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    45
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    46
    timeDiff = difftime(cur_time, ref_time);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    47
    numDays = fpcrtl_round(timeDiff / 3600 / 24) + num_days_between_1900_1980 + 1;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    48
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    49
    fpcrtl_printf("[date] tim diff: %f\n", timeDiff);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    50
    fpcrtl_printf("[date] num days between 1980 and today:  %d\n", fpcrtl_round(timeDiff/3600/24));
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    51
    fpcrtl_printf("[date] current date: %s\n", asctime(&cur_date));
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    52
    fpcrtl_printf("[date] reference date: %s\n", asctime(&ref_date));
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    53
    fpcrtl_printf("[date] num days: %d\n", numDays);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    54
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    55
    return numDays;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    56
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    57
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    58
TDateTime fpcrtl_time()
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    59
{
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    60
    struct tm cur_date;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    61
    time_t local_time;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    62
    time_t cur_time;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    63
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    64
    double day_time_frac; //fraction that represents the time in one day
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    65
    int num_seconds;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    66
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    67
    local_time = time(NULL);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    68
    cur_date = *localtime(&local_time);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    69
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    70
    num_seconds = cur_date.tm_hour * 3600 + cur_date.tm_min * 60 + cur_date.tm_sec;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    71
    day_time_frac = num_seconds / 3600.0 / 24.0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    72
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    73
    fpcrtl_printf("%f\n", day_time_frac);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    74
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    75
    return day_time_frac;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    76
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    77
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    78
TDateTime fpcrtl_now()
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    79
{
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    80
    return fpcrtl_date() + fpcrtl_time();
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    81
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    82
14913
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    83
// Semi-dummy implementation of FormatDateTime
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    84
string255 fpcrtl_formatDateTime(string255 FormatStr, TDateTime DateTime)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
    85
{
14913
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    86
    string255 buffer = STRINIT(FormatStr.str);
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    87
    time_t rawtime;
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    88
    struct tm* my_tm;
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    89
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    90
    // DateTime is ignored, always uses current time.
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    91
    // TODO: Use DateTime argument properly.
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    92
    time(&rawtime);
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    93
    my_tm = localtime(&rawtime);
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    94
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    95
    // Currently uses a hardcoded format string, FormatStr is ignored.
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    96
    // The format strings for C and Pascal differ!
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    97
    // TODO: Use FormatStr argument properly.
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    98
    size_t len = strftime(buffer.str, sizeof(buffer.str), "%Y-%m-%d-%H-%M-%S-0", my_tm);
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
    99
    buffer.len = len;
68e1783762bc Pas2C: Support FileSize and Delete; add dummy implementation of FormatDateTime
Wuzzy <Wuzzy2@mail.ru>
parents: 10564
diff changeset
   100
    return buffer;
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   101
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   102
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   103
string255 fpcrtl_trim(string255 s)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   104
{
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   105
    int left, right;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   106
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   107
    if(s.len == 0){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   108
        return s;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   109
    }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   110
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   111
    for(left = 0; left < s.len; left++)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   112
    {
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   113
        if(s.str[left] != ' '){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   114
            break;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   115
        }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   116
    }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   117
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   118
    for(right = s.len - 1; right >= 0; right--)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   119
    {
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   120
        if(s.str[right] != ' '){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   121
            break;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   122
        }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   123
    }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   124
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   125
    if(left > right){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   126
        s.len = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   127
        s.str[0] = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   128
        return s;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   129
    }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   130
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   131
    s.len = right - left + 1;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   132
    memmove(s.str, s.str + left, s.len);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   133
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   134
    s.str[s.len] = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   135
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   136
    return s;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   137
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   138
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   139
Integer fpcrtl_strToInt(string255 s)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   140
{
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   141
    s.str[s.len] = 0;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   142
    return atoi(s.str);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   143
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   144
10564
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   145
string255 fpcrtl_extractFileDir(string255 f)
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   146
{
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   147
    const char sep[] = {'\\', '/', ':'};
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   148
    LongInt i,j;
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   149
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   150
    i = f.len - 1;
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   151
    while(i >= 0){
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   152
        for(j = 0; j < sizeof(sep); j++){
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   153
            if(f.str[i] == sep[j]){
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   154
                goto FPCRTL_EXTRACTFILEDIR_END;
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   155
            }
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   156
        }
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   157
        i--;
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   158
    }
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   159
FPCRTL_EXTRACTFILEDIR_END:
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   160
    return fpcrtl_copy(f, 1, i);
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   161
}
0cb20aa8877a more fixing and allow pas2c to run tests. they will still fail though - engine does not exit with the specified exit codes, also data types are messed up
sheepluva
parents: 10137
diff changeset
   162
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   163
//function ExtractFileName(const FileName: string): string;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   164
//var
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   165
//  i : longint;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   166
//  EndSep : Set of Char;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   167
//begin
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   168
//  I := Length(FileName);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   169
//  EndSep:=AllowDirectorySeparators+AllowDriveSeparators;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   170
//  while (I > 0) and not (FileName[I] in EndSep) do
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   171
//    Dec(I);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   172
//  Result := Copy(FileName, I + 1, MaxInt);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   173
//end;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   174
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   175
string255 fpcrtl_extractFileName(string255 f)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   176
{
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   177
    const char sep[] = {'\\', '/', ':'};
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   178
    LongInt i,j;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   179
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   180
    i = f.len - 1;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   181
    while(i >= 0){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   182
        for(j = 0; j < sizeof(sep); j++){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   183
            if(f.str[i] == sep[j]){
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   184
                goto FPCRTL_EXTRACTFILENAME_END;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   185
            }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   186
        }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   187
        i--;
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   188
    }
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   189
FPCRTL_EXTRACTFILENAME_END:
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   190
    return fpcrtl_copy(f, i + 2, 256);
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   191
}
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   192
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   193
string255 fpcrtl_strPas(PChar p)
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   194
{
10137
a4537aab4117 NULL PChar is okay
unc0rr
parents: 10015
diff changeset
   195
    return fpcrtl_pchar2str(p);
10015
4feced261c68 partial merge of the webgl branch
koda
parents: 8047
diff changeset
   196
}