![]() |
|
|
#17
|
|||
|
|||
|
Цитата:
|
|
#18
|
|||
|
|||
|
randy, возможно, тебе поможет функция matchesmask в модуле masks. Можешь посмотреть реализацию этой функции в этом модуле и сделать что нибудь свое, подходящее под твою задачу
|
|
#19
|
|||
|
|||
|
Where can i find matchesmask in the FAQ give me the Link
Russian ( Google Translate ) : Где я могу найти matchesmask в FAQ дайте мне ссылку? |
|
#20
|
||||
|
||||
|
See Delphi Help
Add Unit Masks In Your Project. Delphi syntax: function MatchesMask(const Filename, Mask: string): Boolean; Description Call MatchesMask to check the Filename parameter using the Mask parameter to describe valid values. A valid mask consists of literal characters, sets, and wildcards. Each literal character must match a single character in the string. The comparison to literal characters is case-insensitive. Each set begins with an opening bracket ([) and ends with a closing bracket (]). Between the brackets are the elements of the set. Each element is a literal character or a range. Ranges are specified by an initial value, a dash (-), and a final value. Do not use spaces or commas to separate the elements of the set. A set must match a single character in the string. The character matches the set if it is the same as one of the literal characters in the set, or if it is in one of the ranges in the set. A character is in a range if it matches the initial value, the final value, or falls between the two values. All comparisons are case-insensitive. If the first character after the opening bracket of a set is an exclamation point (!), then the set matches any character that is not in the set. Wildcards are asterisks (*) or question marks (?). An asterisk matches any number of characters. A question mark matches a single arbitrary character. MatchesMask returns true if the string matches the mask. MatchesMask returns false if the string does not match the mask. MatchesMask raises an exception if the mask is syntactically invalid. Note: The Filename parameter does not need to be a file name. MatchesMask can be used to check strings against any syntactically correct mask. Последний раз редактировалось Vayrus, 23.01.2009 в 00:27. |
|
#21
|
|||
|
|||
|
MatchesMask Is using when you want to compare between FileNames :
Like This : const s = 'http://www.delphisources.ru'; MatchesMask(s,'h?p://*') == FALSE MatchesMask(s,'h??p://*') == TRUE MatchesMask(s,'http://*') == TRUE MatchesMask(s,'http://*.ru') == TRUE MatchesMask(s,'http://*.net') == FALSE But what i'm doing is Looking in Strings not Files . That's why i used the FastPos from the FastStrings . I will show you here : if (FastPos( s, lVirus^.Signature, sLen, lVirus^.SigLen, 1) > 0) then result := gSignatures.IndexOf(lVirus); S: is the Buffer i'm searching In . lVirus^.Signature : is the Pattern i'm using ( Virus Signature ) sLen : the Buffer Length i'm searching in this will narrow the Pattern and fasten the scanning. lVirus^.SigLen: the Virus Signature Length , why i use it because if we find a Virus with a 255 Signature then don't use this Length for all othere Viruses , but Use an othere Signature Length . 1: Is the Default Start Point in FastPos in FastStrings otherwise you will get nothing . Many thanks . Последний раз редактировалось randy, 23.01.2009 в 00:53. |
|
#22
|
|||
|
|||
|
Не понял, чё он написал. То ли вопрос, то ли ответ.
Ну если примерно, то первой строчкой он сообщает нам, что "MatchesMask" используется для сравнения между "FileNames" //But what i'm doing is Looking in Strings not Files . Но что я делаю смотря в строку без файла.(Да перевод слишком примерный) //That's why i used the FastPos from the FastStrings . Поэтому я использую "FastPos" из "FastStrings" //I will show you here : Я покажу вам на примере: if (FastPos( s,lVirus^.Signature,sLen,lVirus^.SigLen, 1) > 0) then result := gSignatures.IndexOf(lVirus); "S" - это буфер, в который он прописывает результаты поиска "lVirus^.Signature" - это образец, который я использую (* - примечание переводчика - "вроде как специальный тип") "sLen" - тоже буфер, в который я использую для более конкретного образца и быстрого сканирования файлов "lVirus^.SigLen" - длина электронной цифровой подписи вируса, зачем я её использую, потому что если я найду 255 цифровых подписей, то нельзя будет использовать эту длину подписи для всех вирусов, но ...(* примечание переводчика - не понял) 1: это детальная точка старта в "FastPos" в "FastStrings", иначе ты можешь ничего не получить. Спасибо, спасибо, спасибо . Мне нечего написать по теме, перевёл для себя, и чтобы другие "англичане" не тратили время на примерный перевод P.S. Randy, you don't written thanks for me. I don't written anything very good. Better, sad thanks for Vayrus. Последний раз редактировалось DungeonLords, 23.01.2009 в 11:25. |
|
#23
|
||||
|
||||
|
Я так понял что ему надо сканировать по маске еще и файлы в сети, поправьте если ошибаюсь
You it is necessary to scan the files in network ??? |
|
#24
|
|||
|
|||
|
Ему походу надо работать не именами файлами, а с текстом, если не ошибаюсь.
Код:
//T - text; M - mask; Sp - StartPos; result - position (index) in text
//if Substr is not found, function returns zero.
function MatchesMaskEx(T, M: string; Sp: integer): integer;
var
Tl, Ml: integer; // length of file name and mask
Tp, Mp: integer; // pointers
first: boolean;
begin
T := UpperCase(T);
M := UpperCase(M);
result := 0;
Tl := length(T);
Ml := length(M);
Tp := Sp;
Mp := 1;
first := false;
while Mp <= Ml do
begin // wildcard
case M[Mp] of //
'?':
begin // if one any char
inc(Mp); // next char of mask
inc(Tp); // next char of file name
end; //
' * ':
begin // if any chars
if Mp = Ml then
exit; // if last char in mask then exit
if M[Mp + 1] = T[Tp] then
begin // if next char in mask equate char in
Inc(Mp); // file name then next char in mask and
end
else
begin // else
if Tp = Tl then
begin // if last char in file name then
result := 0; // function return false
exit; //
end; // else, if not previous, then
inc(Tp); // next char in file name
end; //
end; //
else
begin // other char in mask
if M[Mp] <> T[Tp] then
begin // if char in mask not equate char in
Mp := 1;
first := false;
continue;
end; // else
if (Mp = Ml) and (Tp <> Tl) then begin
Result := 0;
exit;
end;
if first = false then begin
first := true;
Result := Tp;
end;
inc(Tp); // next char of mask
inc(Mp); // next char of file name
end
end;
end;
end;
|
|
#25
|
|||
|
|||
|
Цитата:
Of Course my friend . |
|
#26
|
||||
|
||||
|
Наверно криво написал
Speak to BlackCash, he has too written antiviruses, can he will help you. ![]() |
|
#27
|
|||
|
|||
|
I'm Looking for him , if i find him i will kill him
![]() |