| 44 |
static BOOL FileRetrySend, FileRetryEcho, FileCRSend, FileReadEOF, BinaryMode; |
static BOOL FileRetrySend, FileRetryEcho, FileCRSend, FileReadEOF, BinaryMode; |
| 45 |
static BYTE FileByte; |
static BYTE FileByte; |
| 46 |
|
|
| 47 |
|
#define FILE_SEND_BUF_SIZE 8192 |
| 48 |
|
struct FileSendHandler { |
| 49 |
|
CHAR buf[FILE_SEND_BUF_SIZE]; |
| 50 |
|
int pos; |
| 51 |
|
int end; |
| 52 |
|
}; |
| 53 |
|
static struct FileSendHandler FileSendHandler; |
| 54 |
|
static int FileDlgRefresh; |
| 55 |
|
|
| 56 |
static int FileBracketMode = FS_BRACKET_NONE; |
static int FileBracketMode = FS_BRACKET_NONE; |
| 57 |
static int FileBracketPtr = 0; |
static int FileBracketPtr = 0; |
| 58 |
static char BracketStartStr[] = "\033[200~"; |
static char BracketStartStr[] = "\033[200~"; |
| 1121 |
SendVar->FileHandle = _lopen(SendVar->FullName,OF_READ); |
SendVar->FileHandle = _lopen(SendVar->FullName,OF_READ); |
| 1122 |
#else |
#else |
| 1123 |
SendVar->FileHandle = (int)CreateFile(SendVar->FullName, GENERIC_READ, FILE_SHARE_READ, NULL, |
SendVar->FileHandle = (int)CreateFile(SendVar->FullName, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 1124 |
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); |
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); |
| 1125 |
#endif |
#endif |
| 1126 |
SendVar->FileOpen = (SendVar->FileHandle>0); |
SendVar->FileOpen = (SendVar->FileHandle>0); |
| 1127 |
if (! SendVar->FileOpen) |
if (! SendVar->FileOpen) |
| 1137 |
FileRetryEcho = FALSE; |
FileRetryEcho = FALSE; |
| 1138 |
FileCRSend = FALSE; |
FileCRSend = FALSE; |
| 1139 |
FileReadEOF = FALSE; |
FileReadEOF = FALSE; |
| 1140 |
|
FileSendHandler.pos = 0; |
| 1141 |
|
FileSendHandler.end = 0; |
| 1142 |
|
FileDlgRefresh = 0; |
| 1143 |
|
|
| 1144 |
if (BracketedPasteMode()) { |
if (BracketedPasteMode()) { |
| 1145 |
FileBracketMode = FS_BRACKET_START; |
FileBracketMode = FS_BRACKET_START; |
| 1212 |
} |
} |
| 1213 |
|
|
| 1214 |
extern "C" { |
extern "C" { |
| 1215 |
|
// 以下の時はこちらの関数を使う |
| 1216 |
|
// - BinaryMode == true |
| 1217 |
|
// - FileRetryEcho == false |
| 1218 |
|
// - FileBracketMode == false |
| 1219 |
|
// - cv.TelFlag == false |
| 1220 |
|
// - ts.LocalEcho == 0 |
| 1221 |
|
void FileSendBinayBoost() |
| 1222 |
|
{ |
| 1223 |
|
WORD c, fc; |
| 1224 |
|
LONG BCOld; |
| 1225 |
|
DWORD read_bytes; |
| 1226 |
|
|
| 1227 |
|
if ((SendDlg == NULL) || |
| 1228 |
|
((cv.FilePause & OpSendFile) != 0)) |
| 1229 |
|
return; |
| 1230 |
|
|
| 1231 |
|
BCOld = SendVar->ByteCount; |
| 1232 |
|
|
| 1233 |
|
if (FileRetrySend) |
| 1234 |
|
{ |
| 1235 |
|
c = CommRawOut(&cv, &(FileSendHandler.buf[FileSendHandler.pos]), |
| 1236 |
|
FileSendHandler.end - FileSendHandler.pos); |
| 1237 |
|
FileSendHandler.pos += c; |
| 1238 |
|
FileRetrySend = (FileSendHandler.end != FileSendHandler.pos); |
| 1239 |
|
if (FileRetrySend) |
| 1240 |
|
return; |
| 1241 |
|
} |
| 1242 |
|
|
| 1243 |
|
do { |
| 1244 |
|
if (FileSendHandler.pos == FileSendHandler.end) { |
| 1245 |
|
#ifdef FileVarWin16 |
| 1246 |
|
fc = _lread(SendVar->FileHandle, &(FileSendHandler.buf[0]), sizeof(FileSendHandler.buf)); |
| 1247 |
|
#else |
| 1248 |
|
ReadFile((HANDLE)SendVar->FileHandle, &(FileSendHandler.buf[0]), sizeof(FileSendHandler.buf), &read_bytes, NULL); |
| 1249 |
|
fc = LOWORD(read_bytes); |
| 1250 |
|
#endif |
| 1251 |
|
FileSendHandler.pos = 0; |
| 1252 |
|
FileSendHandler.end = fc; |
| 1253 |
|
} else { |
| 1254 |
|
fc = FileSendHandler.end - FileSendHandler.end; |
| 1255 |
|
} |
| 1256 |
|
|
| 1257 |
|
if (fc != 0) |
| 1258 |
|
{ |
| 1259 |
|
c = CommRawOut(&cv, &(FileSendHandler.buf[FileSendHandler.pos]), |
| 1260 |
|
FileSendHandler.end - FileSendHandler.pos); |
| 1261 |
|
FileSendHandler.pos += c; |
| 1262 |
|
FileRetrySend = (FileSendHandler.end != FileSendHandler.pos); |
| 1263 |
|
SendVar->ByteCount = SendVar->ByteCount + c; |
| 1264 |
|
if (FileRetrySend) |
| 1265 |
|
{ |
| 1266 |
|
if (SendVar->ByteCount != BCOld) |
| 1267 |
|
SendDlg->RefreshNum(); |
| 1268 |
|
return; |
| 1269 |
|
} |
| 1270 |
|
} |
| 1271 |
|
FileDlgRefresh = SendVar->ByteCount; |
| 1272 |
|
SendDlg->RefreshNum(); |
| 1273 |
|
BCOld = SendVar->ByteCount; |
| 1274 |
|
if (fc != 0) |
| 1275 |
|
return; |
| 1276 |
|
} while (fc != 0); |
| 1277 |
|
|
| 1278 |
|
FileTransEnd(OpSendFile); |
| 1279 |
|
} |
| 1280 |
|
} |
| 1281 |
|
|
| 1282 |
|
extern "C" { |
| 1283 |
void FileSend() |
void FileSend() |
| 1284 |
{ |
{ |
| 1285 |
WORD c, fc; |
WORD c, fc; |
| 1286 |
LONG BCOld; |
LONG BCOld; |
| 1287 |
DWORD read_bytes; |
DWORD read_bytes; |
| 1288 |
|
|
| 1289 |
|
if (BinaryMode && !FileRetryEcho && !FileBracketMode && !cv.TelFlag && |
| 1290 |
|
(ts.LocalEcho == 0) && (ts.Baud >= 115200)) { |
| 1291 |
|
return FileSendBinayBoost(); |
| 1292 |
|
} |
| 1293 |
|
|
| 1294 |
if ((SendDlg==NULL) || |
if ((SendDlg==NULL) || |
| 1295 |
((cv.FilePause & OpSendFile) !=0)) |
((cv.FilePause & OpSendFile) !=0)) |
| 1296 |
return; |
return; |