Pewien problem z podzialem pliku na nazwe i rozszerzenie

0

Na wstepie zapytam czy w Builderze sa dostepne funkcje ktore nazwe pliku (plik.txt) bedacego stringiem podzielą na takie czesci:

plik po wywolanie funkcji np. pobierz nazwe
txt po wywolaniu funkcji np. daj rozszerzenie

Ponizej probuje cos takiego zrobic ale jeszcze nie wiem do konca jak, może ktos wie to niech poprawi blad.

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent
Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
int reversePos(String substr,String s,bool caseSensitive=false)
{
int i,j;

if(caseSensitive)
{
substr=substr.LowerCase();
s=s.LowerCase();
}

j=substr.Length();
i=s.Length();

for(i;i>1;i--)
{
if(s[i]==substr[j])
{
j=j-1;
if(j==0)
{
return i;
exit;
}
}
continue;
}

}

String getFileNameNoExt(String name) //wez nazwe bez rozszerzenia
{
int pos;
if(name=="..")
return name;
exit;

pos=reversePos('.',name,false);
if(pos!=0)
return copy(name,1,pos-1);
return name;
}

String getFileExt(String name) //wez nazwe z rozszerzeniem
{
int pos;

pos=reversePos('.',name,false);

if(pos!=0)
return copy(name,pos+1,name.Length()-pos+1);
else
return '';
}

0
ExtractFileExt()
ExtractFileName()

1 użytkowników online, w tym zalogowanych: 0, gości: 1