From e13a0cf0407e7994508c7380a149432a8f484dc5 Mon Sep 17 00:00:00 2001 From: mysticbbs Date: Sat, 6 Apr 2013 23:58:33 -0400 Subject: [PATCH] A30 --- mdl/m_datetime.pas | 13 ++++++++++++- mdl/m_fileio.pas | 18 ++++++++++++++++-- mdl/m_output_windows.pas | 26 +++++++++----------------- mdl/m_protocol_queue.pas | 9 +++++++-- mdl/m_protocol_zmodem.pas | 2 +- mdl/m_socket_server.pas | 2 +- 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/mdl/m_datetime.pas b/mdl/m_datetime.pas index 3b8481d..ae62774 100644 --- a/mdl/m_datetime.pas +++ b/mdl/m_datetime.pas @@ -4,6 +4,9 @@ Unit m_DateTime; Interface +Uses + DOS; + Const DayString : Array[0..6] of String[3] = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); MonthString : Array[1..12] of String[3] = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); @@ -15,6 +18,7 @@ Function TimerSet (Secs: LongInt) : LongInt; Function TimerUp (Secs: LongInt) : Boolean; Function CurDateDos : LongInt; Function CurDateJulian : LongInt; +Function CurDateDT : DateTime; Function DateDos2Str (Date: LongInt; Format: Byte) : String; Function DateJulian2Str (Date: LongInt; Format: Byte) : String; Function DateStr2Dos (Str: String) : LongInt; @@ -36,7 +40,6 @@ Uses {$IFDEF UNIX} BaseUnix, {$ENDIF} - DOS, m_Strings; Const @@ -141,6 +144,14 @@ Begin DateG2J(Date.Year, Date.Month, Date.Day, Result); End; +Function CurDateDT : DateTime; +Var + Temp : Word; +Begin + GetDate (Result.Year, Result.Month, Result.Day, Temp); + GetTime (Result.Hour, Result.Min, Result.Sec, Temp); +End; + Function TimerSeconds : LongInt; Var Hour, diff --git a/mdl/m_fileio.pas b/mdl/m_fileio.pas index 9669e39..77bd73a 100644 --- a/mdl/m_fileio.pas +++ b/mdl/m_fileio.pas @@ -43,6 +43,7 @@ Function FileRename (OldFN, NewFN: String) : Boolean; Function FileCopy (Source, Target: String) : Boolean; Function FileFind (FN: String) : String; Function FileByteSize (FN: String) : Int64; +Function FileNewExt (FN, NewExt: String) : String; { GLOBAL FILEIO VARIABLES AND CONSTANTS } @@ -170,7 +171,7 @@ Begin ioCode := 5; While (Count < ioRetries) and (ioCode = 5) Do Begin - Seek (F, FPos); + {$I-} Seek (F, FPos); {$I+} ioCode := IoResult; Inc (Count); If ioCode = 5 Then WaitMS(ioWaitTime); @@ -221,7 +222,7 @@ Begin ioCode := 5; While (Count < ioRetries) and (ioCode = 5) Do Begin - BlockRead (F, Rec, 1); + {$I-} BlockRead (F, Rec, 1); {$I+} ioCode := IoResult; Inc (Count); If ioCode = 5 Then WaitMS(ioWaitTime); @@ -833,4 +834,17 @@ Begin FindClose (DirInfo); End; +Function FileNewExt (FN, NewExt: String) : String; +Var + Temp : Byte; +Begin + For Temp := Length(FN) DownTo 1 Do + If FN[Temp] = '.' Then Begin + Result := Copy(FN, 1, Temp) + NewExt; + Exit; + End; + + Result := FN + '.' + NewExt; +End; + End. diff --git a/mdl/m_output_windows.pas b/mdl/m_output_windows.pas index bfe60c2..55c355b 100644 --- a/mdl/m_output_windows.pas +++ b/mdl/m_output_windows.pas @@ -169,34 +169,25 @@ End; Procedure TOutputWindows.ClearEOL; Var - Buf : Array[1..80] of TCharInfo; - Count : Byte; - BufSize : TCoord; - BufCoord : TCoord; - Region : TSmallRect; + Buf : Array[1..80] of TCharInfo; + Count : Byte; + Res : LongInt; Begin + If Window.Right = Cursor.X Then Exit; + Count := 0; While Count <= Window.Right - Cursor.X Do Begin Inc (Count); + Buf[Count].Attributes := TextAttr; Buf[Count].UnicodeChar := ' '; End; Move(Buf[1], Buffer[Cursor.Y + 1][Cursor.X + 1], SizeOf(TCharInfo) * Count); - If Active Then Begin - BufSize.X := Count; - BufSize.Y := 1; - BufCoord.X := 0; - BufCoord.Y := 0; - Region.Left := Cursor.X; - Region.Top := Cursor.Y; - Region.Right := Cursor.X + Count - 1; - Region.Bottom := Cursor.Y; - - WriteConsoleOutput(ConOut, @Buf, BufSize, BufCoord, Region); - End; + If Active Then + FillConsoleOutputCharacter (ConOut, ' ', Count, Cursor, @Res); End; Procedure TOutputWindows.ClearScreenNoUpdate; @@ -264,6 +255,7 @@ Begin While Count <= Length(Text) Do Begin Buf[Count].Attributes := A; Buf[Count].UnicodeChar := Text[Count]; + Inc (Count); End; diff --git a/mdl/m_protocol_queue.pas b/mdl/m_protocol_queue.pas index 6fc190c..6f10593 100644 --- a/mdl/m_protocol_queue.pas +++ b/mdl/m_protocol_queue.pas @@ -20,6 +20,7 @@ Type TProtocolQueueRec = Record FilePath : String[QueueMaxPathSize]; FileName : String[QueueMaxNameSize]; + FileNew : String[QueueMaxNameSize]; FileSize : Int64; Status : Byte; End; @@ -33,7 +34,7 @@ Type Constructor Create; Destructor Destroy; Override; - Function Add (fPath, fName: String) : Boolean; + Function Add (fPath, fName, fNew: String) : Boolean; Procedure Delete (Idx: Word); Procedure Clear; Function Next : Boolean; @@ -55,7 +56,7 @@ Begin Clear; End; -Function TProtocolQueue.Add (fPath, fName: String) : Boolean; +Function TProtocolQueue.Add (fPath, fName, fNew: String) : Boolean; Var F : File; Begin @@ -69,8 +70,12 @@ Begin QData[QSize]^.FilePath := fPath; QData[QSize]^.FileName := fName; + QData[QSize]^.FileNew := fNew; QData[Qsize]^.FileSize := 0; + If fNew = '' Then + QData[QSize]^.FileNew := fName; + Assign (F, fPath + fName); {$I-} Reset(F, 1); {$I+} diff --git a/mdl/m_protocol_zmodem.pas b/mdl/m_protocol_zmodem.pas index a8d0bb5..df9545c 100644 --- a/mdl/m_protocol_zmodem.pas +++ b/mdl/m_protocol_zmodem.pas @@ -1481,7 +1481,7 @@ Begin {$IFDEF ZDEBUG} ZLog('ZRecvFile -> File:' + FName); {$ENDIF} {$IFDEF ZDEBUG} ZLog('ZRecvFile -> Size:' + strI2S(FSize)); {$ENDIF} - Queue.Add(ReceivePath, FName); + Queue.Add(ReceivePath, FName, ''); Queue.QData[Queue.QSize]^.FileSize := FSize; Queue.QData[Queue.QSize]^.Status := QueueIntransit; diff --git a/mdl/m_socket_server.pas b/mdl/m_socket_server.pas index 50b74ce..7688abb 100644 --- a/mdl/m_socket_server.pas +++ b/mdl/m_socket_server.pas @@ -98,7 +98,7 @@ Begin If ServerStatus.Count > MaxStatusText Then ServerStatus.Delete(0); - Res := '(' + Copy(DateDos2Str(CurDateDos, 1), 1, 5) + ' ' + TimeDos2Str(CurDateDos, False) + ') ' + Str; + Res := '(' + Copy(DateDos2Str(CurDateDos, 1), 1, 5) + ' ' + TimeDos2Str(CurDateDos, 0) + ') ' + Str; If Length(Res) > 74 Then Begin ServerStatus.Add(Copy(Res, 1, 74));