Ejemplo n.º 1
0
Archivo: error.c Proyecto: E-LLP/QuIP
static int silent(SINGLE_QSP_ARG_DECL)
{
	char *s;

	if( ! SILENCE_CHECKED(THIS_QSP) ){
		SET_QS_FLAG_BITS(THIS_QSP,QS_SILENCE_CHECKED);
		s=getenv("SILENT");
		if( s == NULL )
			CLEAR_QS_FLAG_BITS(THIS_QSP,QS_SILENT);
		else {
			if( *s == '0' )
				CLEAR_QS_FLAG_BITS(THIS_QSP,QS_SILENT);
			else
				SET_QS_FLAG_BITS(THIS_QSP,QS_SILENT);
		}
	}
	return( IS_SILENT(THIS_QSP) );
}
Ejemplo n.º 2
0
BOOL FtpFindFirstFile(Connection *hConnect, LPCSTR lpszSearchFile,FTPFileInfo* lpFindFileData, BOOL *ResetCache)
{
	Assert(hConnect && "FtpFindFirstFile");
	String Command;
	int    AllFiles = StrCmp(lpszSearchFile,"*")==0 ||
	                  StrCmp(lpszSearchFile,"*.*")==0;
	int    FromCache = 0;

	if(ResetCache && *ResetCache == TRUE)
	{
		hConnect->CacheReset();
		FtpGetFtpDirectory(hConnect);
		*ResetCache = FALSE;
	}

	if(AllFiles)
		Command = "dir";
	else
	{
		if(*lpszSearchFile=='/')
			lpszSearchFile = PointToName((char *)lpszSearchFile);

		Command.printf("dir \x1%s\x1", lpszSearchFile);
	}

	WINPORT(SetLastError)(ERROR_SUCCESS);

	if(!AllFiles || (FromCache=hConnect->CacheGet()) == 0)
	{
		if(AllFiles && !IS_SILENT(FP_LastOpMode) &&
		        hConnect->CmdVisible &&
		        hConnect->CurrentState != fcsExpandList)
			hConnect->ConnectMessage(MRequestingFolder,
			                         hConnect->CurDir.c_str());
//			                         hConnect->ToOEMDup(hConnect->CurDir.c_str()));

		int pc = hConnect->ProcessCommand(Command);

		if(!pc)
		{
			if(hConnect->Host.ServerType==FTP_TYPE_MVS)
			{
				if(hConnect->code==550)
				{
					pc = 1;  //550 No members found.
				}

				if(hConnect->code==501&&AllFiles)
				{
					Command="dir *";
					pc = hConnect->ProcessCommand(Command);
				}
			}

			if(!pc)
			{
				WINPORT(SetLastError)(hConnect->ErrorCode);
				return FALSE;
			}
		}
	}

	if(AllFiles && !FromCache)
		hConnect->CacheAdd();

	return ParseDirLine(hConnect,AllFiles,lpFindFileData);
}
Ejemplo n.º 3
0
int FTP::GetFindData(PluginPanelItem **pPanelItem, int *pItemsNumber, int OpMode)
{
	PROC(("FTP::GetFindData",NULL))
	DWORD        b,e;
	char            *Data[3];
	*pPanelItem   = NULL;
	*pItemsNumber = 0;

//Hosts
	if(ShowHosts)
	{
		EnumHost        Enum(HostsPath);
		FP_SizeItemList il(FALSE);
		PluginPanelItem tmp;
		FTPHost         h;

		if(!IS_SILENT(OpMode))
		{
			memset(&tmp, 0, sizeof(tmp));
			strcpy(tmp.FindData.cFileName,"..");
			tmp.FindData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;

			if(!IS_SILENT(OpMode))
			{
				tmp.Description               = (char *)"..";
				tmp.CustomColumnNumber        = 3;
				tmp.CustomColumnData          = Data;
				tmp.CustomColumnData[0]       = (char *)"..";
				tmp.CustomColumnData[1]       = (char *)"..";
				tmp.CustomColumnData[2]       = (char *)"..";
			}

			if(!il.Add(&tmp))
				return FALSE;
		}

		while(true)
		{
			if(!Enum.GetNextHost(&h))
				break;

			if(!h.Read(NULL))
				continue;

			memset(&tmp, 0, sizeof(tmp));
			/* Panel item MUST have name the save as file saved to disk
			   in case you want to copy between panels work.
			*/
			h.MkINIFile(tmp.FindData.cFileName,NULL,"");
			tmp.FindData.ftLastWriteTime  = h.LastWrite;
			tmp.FindData.dwFileAttributes = h.Folder ? FILE_ATTRIBUTE_DIRECTORY : 0;
			tmp.Flags                     = PPIF_USERDATA;
			tmp.PackSizeHigh              = FTP_HOSTID;
			tmp.UserData                  = (DWORD_PTR)&h;

			if(!IS_SILENT(OpMode))
			{
				tmp.Description               = h.HostDescr;
				tmp.CustomColumnNumber        = 3;
				tmp.CustomColumnData          = Data;
				tmp.CustomColumnData[0]       = h.Host;  //C0
				tmp.CustomColumnData[1]       = h.Home;  //C1
				tmp.CustomColumnData[2]       = h.User;  //C2
			}

			if(!il.Add(&tmp))
				return FALSE;

			Log(("Item[%d]=[%s] attr=%08X",
			     il.Count()-1, FTP_FILENAME(il.Item(il.Count()-1)),
			     il.Item(il.Count()-1)->FindData.dwFileAttributes));
		}

		*pPanelItem   = il.Items();
		*pItemsNumber = il.Count();
		return TRUE;
	}

//FTP
	FP_Screen _scr;
	FTPFileInfo FileInfo;

	if(!hConnect)
	{
		goto AskConnect;
	}

Restart:

	if(!FtpFindFirstFile(hConnect, "*", &FileInfo, &ResetCache))
	{
		if(GetLastError() == ERROR_NO_MORE_FILES)
		{
			*pItemsNumber = 0;
			return TRUE;
		}

		if(SwitchingToFTP && GetLastError() == ERROR_CANCELLED)
		{
			;
		}
		else
		{
			if(CurrentState == fcsExpandList)
			{
				FreeFindData(*pPanelItem,*pItemsNumber);
				*pPanelItem   = NULL;
				*pItemsNumber = 0;
				return FALSE;
			}

//Query reconnect
			do
			{
				if(!hConnect)
					break;

				if(GetLastError() == ERROR_CANCELLED)
					break;

				if(!hConnect->ConnectMessageTimeout(MConnectionLost,Host.HostName,-MRestore))
				{
					Log(("WaitMessage cancelled"));
					break;
				}

				if(FtpCmdLineAlive(hConnect) &&
				        FtpKeepAlive(hConnect))
					goto Restart;

				if(SelectFile.Length() && CurrentState != fcsExpandList)
					SaveUsedDirNFile();

AskConnect:

				if(Connect())
					goto Restart;
				else
					break;
			}
			while(true);
		}

		if(!ShowHosts)
			BackToHosts();

		FreeFindData(*pPanelItem, *pItemsNumber);
		return GetFindData(pPanelItem,pItemsNumber,OpMode);
	}

	GET_TIME(b);

	do
	{
		if(Opt.ShowIdle)
		{
			char str[ 200 ];
			GET_TIME(e);

			if(CMP_TIME(e,b) > 0.5)
			{
				_snprintf(str,ARRAYSIZE(str),"%s%d", FP_GetMsg(MReaded), *pItemsNumber);
				SetLastError(ERROR_SUCCESS);
				IdleMessage(str,Opt.ProcessColor);
				b = e;

				if(CheckForEsc(FALSE))
				{
					SetLastError(ERROR_CANCELLED);
					return FALSE;
				}
			}
		}

		PluginPanelItem *NewPanelItem=*pPanelItem;

		if((*pItemsNumber % 1024) == 0)
		{
			if(!NewPanelItem)
				NewPanelItem = (PluginPanelItem *)malloc((1024+1)*sizeof(PluginPanelItem));
			else
				NewPanelItem = (PluginPanelItem *)realloc(NewPanelItem,(*pItemsNumber+1024+1)*sizeof(PluginPanelItem));

			if(NewPanelItem == NULL)
			{
				/*-*/Log(("GetFindData(file)::!reallocate plugin panels items %d -> %d",*pItemsNumber,*pItemsNumber+1024+1));
				return FALSE;
			}

			*pPanelItem=NewPanelItem;
		}

		PluginPanelItem *CurItem = &NewPanelItem[*pItemsNumber];
		memset(CurItem, 0, sizeof(PluginPanelItem));
		CurItem->FindData = FileInfo.FindData;

		if(!IS_SILENT(OpMode))
		{
			CurItem->CustomColumnNumber             = FTP_COL_MAX;
			CurItem->Owner                          = FileInfo.FTPOwner[0] ? strdup(FileInfo.FTPOwner) : NULL;
			CurItem->CustomColumnData               = (LPSTR*)malloc(sizeof(LPSTR*)*FTP_COL_MAX);
			CurItem->CustomColumnData[FTP_COL_MODE] = strdup(FileInfo.UnixMode);
			CurItem->CustomColumnData[FTP_COL_LINK] = strdup(FileInfo.Link);
			hConnect->ToOEM(CurItem->CustomColumnData[FTP_COL_LINK]);
		}

		(*pItemsNumber)++;
	}
	while(FtpFindNextFile(hConnect,&FileInfo));

	return TRUE;
}
Ejemplo n.º 4
0
void FTP::GetOpenPluginInfo(struct OpenPluginInfo *pi)
{
	PROC(("GetOpenPluginInfo","%s cc: %d pi: %p hC:%p",ShowHosts?"HOSTS":"FTP",CallLevel,pi,hConnect));
	PanelInfo thisPInfo = { 0 };
	static int inside = 0;
	inside++;
	memset(pi, 0, sizeof(*pi));
	pi->StructSize = sizeof(*pi);

//---------------- FLAGS
	if(!hConnect || ShowHosts)
		pi->Flags = OPIF_SHOWPRESERVECASE | OPIF_USEHIGHLIGHTING;
	else
		pi->Flags = OPIF_ADDDOTS | OPIF_USEFILTER | OPIF_USESORTGROUPS | OPIF_USEHIGHLIGHTING |
		            OPIF_SHOWPRESERVECASE;

	Log(("SetFlags %08X", pi->Flags));
//---------------- HOST, CURDIR
	static String curDir;
	GetCurPath(curDir);
	pi->HostFile = NULL;
	pi->CurDir   = curDir.c_str();
//---------------- TITLE
	pi->PanelTitle = PanelTitle;

	if(ShowHosts)
		_snprintf(PanelTitle, ARRAYSIZE(PanelTitle),
		          " FTP: %s ", pi->CurDir);
	else
		_snprintf(PanelTitle, ARRAYSIZE(PanelTitle),
		          (hConnect&&hConnect->Host.ServerType==FTP_TYPE_MVS)? " FTP: %s@%s/%s ": " FTP: %s@%s%s ",
		          Host.User, Host.Host, pi->CurDir);

	if(inside > 1)
	{
		inside--;
		return;
	}

//---------------- FORMAT
	static String Format;

	if(ShowHosts)
		Format = "//Hosts/";
	else
		Format.printf("//%s/",Host.Host);

	Format.cat(pi->CurDir + (*pi->CurDir == '/' || *pi->CurDir == '\\'));
	pi->Format = Format.c_str();
//---------------- INFO LINES
	static struct InfoPanelLine InfoLines[7];
	char *m;
	memset(InfoLines, 0, sizeof(InfoLines));
//Client
	StrCpy(InfoLines[0].Text,FP_GetMsg(MFtpInfoFTPClient),ARRAYSIZE(InfoLines[0].Text));
	InfoLines[0].Separator = TRUE;
	StrCpy(InfoLines[1].Text,FP_GetMsg(MFtpInfoHostName),ARRAYSIZE(InfoLines[0].Text));
	StrCpy(InfoLines[1].Data,Host.HostName,ARRAYSIZE(InfoLines[0].Data));
	StrCpy(InfoLines[2].Text,FP_GetMsg(MFtpInfoHostDescr),ARRAYSIZE(InfoLines[0].Text));
	StrCpy(InfoLines[2].Data,Host.HostDescr,ARRAYSIZE(InfoLines[0].Data));
	StrCpy(InfoLines[3].Text,FP_GetMsg(MFtpInfoHostType),ARRAYSIZE(InfoLines[0].Text));

	if(hConnect)
		FtpSystemInfo(hConnect,InfoLines[3].Data,ARRAYSIZE(InfoLines[0].Data));
	else
		InfoLines[3].Data[0] = 0;

//Titles
	StrCpy(InfoLines[4].Text,FP_GetMsg(MFtpInfoFtpTitle),ARRAYSIZE(InfoLines[0].Text));
	InfoLines[4].Separator=TRUE;
	InfoLines[5].Text[0] = 0;

	if(hConnect)
		StrCpy(InfoLines[5].Data, hConnect->GetStartReply(), ARRAYSIZE(InfoLines[5].Data));
	else
		InfoLines[5].Data[0] = 0;

	m = strpbrk(InfoLines[5].Data,"\n\r");

	if(m) *m = 0;

	StrCpy(InfoLines[6].Text, FP_GetMsg(MResmResume), ARRAYSIZE(InfoLines[0].Text));

	if(hConnect)
		StrCpy(InfoLines[6].Data, FP_GetMsg(FtpIsResume(hConnect)?MResmSupport:MResmNotSupport), ARRAYSIZE(InfoLines[0].Data));
	else
		StrCpy(InfoLines[6].Data, FP_GetMsg(MResmNotConnected), ARRAYSIZE(InfoLines[0].Data));

	pi->InfoLines       = InfoLines;
	pi->InfoLinesNumber = 7;
//---------------- DESCR
	static char *DescrFiles[32],
	       DescrFilesString[256];
	StrCpy(DescrFilesString, Opt.DescriptionNames, ARRAYSIZE(DescrFilesString));
	int   DescrFilesNumber = 0;
	char *NamePtr          = DescrFilesString;

	while(DescrFilesNumber < (int)ARRAYSIZE(DescrFiles))
	{
		while(isspace(*NamePtr)) NamePtr++;

		if(*NamePtr == 0) break;

		DescrFiles[DescrFilesNumber++] = NamePtr;

		if((NamePtr=strchr(NamePtr,',')) == NULL) break;

		*(NamePtr++)=0;
	}

	pi->DescrFiles=DescrFiles;

	if(!Opt.ReadDescriptions)
		pi->DescrFilesNumber=0;
	else
		pi->DescrFilesNumber=DescrFilesNumber;

//---------------- SHORTCUT
	static String ShortcutData;

	if(ShowHosts)
	{
		/*
		HOSTSTS
		  Hostspath
		*/
		ShortcutData.printf("HOST:%s", HostsPath);
	}
	else
	{
		/*
		FTP
		  Host
		  1
		  AskLogin    + 3
		  AsciiMode   + 3
		  PassiveMode + 3
		  UseFirewall + 3
		  HostTable
		  1
		  User
		  1
		  Password
		  1
		  ExtCmdView + 3
		  IOBuffSize (atoi)
		  1
		  FFDup + '0'
		  DecodeCmdLine + '0'
		  1
		*/
		ShortcutData.printf("FTP:%s\x1%c%c%c%c%d\x1%s\x1%s\x1%s\x1%c%d\x1%c\x1%c\x1",
		                    Host.Host,
		                    Host.AskLogin+3, Host.AsciiMode+3, Host.PassiveMode+3, Host.UseFirewall+3, Host.ServerType,
		                    Host.HostTable,
		                    Host.User,
		                    Host.Password,
		                    Host.ExtCmdView+3, Host.IOBuffSize,
		                    '0'+Host.FFDup, '0'+Host.DecodeCmdLine);
	}

	pi->ShortcutData = ShortcutData.c_str();

//---------------- PANEL MODES
//HOSTST
	if(ShowHosts)
	{
		static struct PanelMode PanelModesArray[10];
		static char *ColumnTitles[4] = { NULL };
		static char *ColumnTitles2[4] = { NULL };
		static char  Mode[ 20 ], ModeSz[20], ModeSz2[20];
		int      dizLen = 0,
		         nmLen  = 0,
		         hLen   = 0,
		         hstLen = 0;
		int      n,num;
		FTPHost* p;
		memset(&PanelModesArray,0,sizeof(PanelModesArray));

		if(!thisPInfo.PanelItems)
			FP_Info->Control(this, FCTL_GETPANELINFO, &thisPInfo);

		for(n = 0; n < thisPInfo.ItemsNumber; n++)
		{
			p = FTPHost::Convert(&thisPInfo.PanelItems[n]);

			if(!p) continue;

			dizLen = Max(dizLen,(int)strlen(p->HostDescr));
			nmLen  = Max(nmLen, (int)strlen(p->User));
			hLen   = Max(hLen, (int)strlen(p->Home));
			hstLen = Max(hstLen,(int)strlen(p->Host));
		}

		ColumnTitles[0] = (char*)FP_GetMsg(MHostColumn);
		//==1
		PanelModesArray[1].ColumnTypes   = (char *)"C0";
		PanelModesArray[1].ColumnWidths  = (char *)"0";
		//==2
		num = 1;
		n   = (thisPInfo.PanelRect.right-thisPInfo.PanelRect.left)/2;
		//HOST
		strcpy(Mode,"C0");
		sprintf(ModeSz,hLen || nmLen || dizLen ? "%d" : "0",hstLen);

		//HOME
		if(hLen)
		{
			strcat(Mode,",C1");

			if(hLen < n && (nmLen || dizLen))
			{
				strcat(ModeSz,Message(",%d",hLen));
				n -= hLen;
			}
			else
				strcat(ModeSz,",0");

			ColumnTitles[num++] = (char*)FP_GetMsg(MHomeColumn);
		}

		//UNAME
		if(nmLen)
		{
			strcat(Mode,",C2");

			if(nmLen < n && dizLen)
			{
				strcat(ModeSz,Message(",%d",nmLen));
			}
			else
				strcat(ModeSz,",0");

			ColumnTitles[num++] = (char*)FP_GetMsg(MUserColumn);
		}

		//DIZ
		if(dizLen)
		{
			strcat(Mode,",Z");
			strcat(ModeSz,",0");
			ColumnTitles[num] = (char*)FP_GetMsg(MDescColumn);
		}

		PanelModesArray[2].ColumnTypes   = Mode;
		PanelModesArray[2].ColumnWidths  = ModeSz;
		PanelModesArray[2].ColumnTitles  = ColumnTitles;
		ColumnTitles2[0] = (char*)FP_GetMsg(MHostColumn);
		ColumnTitles2[1] = (char*)FP_GetMsg(MDescColumn);

		if(!dizLen)
		{
			PanelModesArray[3].ColumnTypes   = (char *)"C0";
			PanelModesArray[3].ColumnWidths  = (char *)"0";
		}
		else
		{
			PanelModesArray[3].ColumnTypes   = (char *)"C0,Z";
			PanelModesArray[3].ColumnWidths  = ModeSz2;
			sprintf(ModeSz2,"%d,0",Min((int)(thisPInfo.PanelRect.right-thisPInfo.PanelRect.left)/2,hstLen));
		}

		PanelModesArray[3].ColumnTitles  = ColumnTitles2;
		pi->PanelModesArray  = PanelModesArray;
		pi->PanelModesNumber = ARRAYSIZE(PanelModesArray);
		pi->StartPanelMode   = 0;

		for(n = 1; n <= 3; n++)
		{
			PanelModesArray[n].StatusColumnTypes   = PanelModesArray[n].ColumnTypes;
			PanelModesArray[n].StatusColumnWidths  = PanelModesArray[n].ColumnWidths;
		}
	}
	else
	{
//FTP
		static struct PanelMode PanelModesArray[10];
		memset(PanelModesArray, 0, sizeof(PanelModesArray));
		static char *ColumnTitles[10];
		SetTitles(ColumnTitles, FP_GetMsg(MColumn9), ARRAYSIZE(ColumnTitles));
		PanelModesArray[9].ColumnTypes  = (char*)FP_GetMsg(MColumn9);
		PanelModesArray[9].ColumnWidths = (char*)FP_GetMsg(MSizes9);
		PanelModesArray[9].ColumnTitles = ColumnTitles;
		PanelModesArray[9].FullScreen   = atoi(FP_GetMsg(MFullScreen9));
		static char *ColumnTitles1[10];
		SetTitles(ColumnTitles1, FP_GetMsg(MColumn0), ARRAYSIZE(ColumnTitles));
		PanelModesArray[0].ColumnTypes  = (char*)FP_GetMsg(MColumn0);
		PanelModesArray[0].ColumnWidths = (char*)FP_GetMsg(MSizes0);
		PanelModesArray[0].ColumnTitles = ColumnTitles1;
		PanelModesArray[0].FullScreen   = atoi(FP_GetMsg(MFullScreen0));
		pi->PanelModesArray  = PanelModesArray;
		pi->PanelModesNumber = ARRAYSIZE(PanelModesArray);
	}

//---------------- KEYBAR
	static struct KeyBarTitles KeyBar;
	memset(&KeyBar,0,sizeof(KeyBar));
	KeyBar.ShiftTitles[1-1] = (char *)"";
	KeyBar.ShiftTitles[2-1] = (char *)"";
	KeyBar.ShiftTitles[3-1] = (char *)"";
	KeyBar.AltTitles[6-1]   = (char*)FP_GetMsg(MAltF6);

	if(ShowHosts)
	{
		KeyBar.ShiftTitles[1-1] = (char*)FP_GetMsg(MShiftF1);
		KeyBar.ShiftTitles[4-1] = ShowHosts ? (char*)FP_GetMsg(MShiftF4):NULL;
	}
	else
	{
		KeyBar.ShiftTitles[1-1] = (char*)FP_GetMsg(MShiftF1);
		KeyBar.ShiftTitles[7-1] = (char*)FP_GetMsg(MShiftF7);
	}

	pi->KeyBar=&KeyBar;

//---------------- RESTORE SCREEN
	if(!SkipRestoreScreen && CurrentState != fcsExpandList && CurrentState != fcsOperation && !IS_SILENT(FP_LastOpMode))
		FP_Screen::FullRestore();

//Back
	inside--;
}
Ejemplo n.º 5
0
BOOL idDeleteCB(PluginPanelItem* p,LPVOID dt)
{
	PROC(("idDeleteCB", "%p,%p [%s]", p, dt, FTP_FILENAME(p)));
	int      rres;
	FTPHost* h       = FTPHost::Convert(p);
	char    *CurName = FTP_FILENAME(p);
	char    *m;

	if(((DeleteData*)dt)->ShowHosts && !h)
		return TRUE;

//Ask
	if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY))
	{
		if(!((DeleteData*)dt)->DeleteAllFolders &&
		        IS_SILENT(((DeleteData*)dt)->OpMode))
		{
			LPCSTR MsgItems[]=
			{
				((DeleteData*)dt)->ShowHosts ? FP_GetMsg(MDeleteHostsTitle):FP_GetMsg(MDeleteTitle),
				((DeleteData*)dt)->ShowHosts ? FP_GetMsg(MDeleteHostFolder):FP_GetMsg(MDeleteFolder),
				CurName,
				FP_GetMsg(MDeleteGroupDelete), FP_GetMsg(MDeleteGroupAll), FP_GetMsg(MDeleteGroupCancel)
			};
			rres = FMessage(FMSG_WARNING|FMSG_DOWN, NULL,
			                MsgItems, ARRAYSIZE(MsgItems),
			                3);

			switch(rres)
			{
					/*ESC*/
				case -1:
					return FALSE;
					/*Del*/
				case  0:
					break;
					/*DelAll*/
				case  1:
					((DeleteData*)dt)->DeleteAllFolders = TRUE;
					break;
					/*Cancel*/
				case  2:
					return FALSE;
			}
		}
	}

//Display
	SaveConsoleTitle::Text(CurName);
	FtpConnectMessage(((DeleteData*)dt)->hConnect, MDeleteTitle, PointToName(CurName));

//===============================
//Hosts
	if(((DeleteData*)dt)->ShowHosts)
		return FP_DeleteRegKeyAll(h->RegKey);

//===============================
//FTP
	m = strrchr(CurName,'/');

	if(m) CurName = m+1;

	if(IS_FLAG(p->FindData.dwFileAttributes,FILE_ATTRIBUTE_DIRECTORY))
	{
//FTP directory
		//Succ delete
		if(FtpRemoveDirectory(((DeleteData*)dt)->hConnect, CurName))
		{
			if(Opt.UpdateDescriptions) p->Flags |= PPIF_PROCESSDESCR;

			return TRUE;
		}
	}
	else
	{
//FTP file
		//Succ delete
		if(FtpDeleteFile(((DeleteData*)dt)->hConnect,CurName))
		{
			if(Opt.UpdateDescriptions) p->Flags |= PPIF_PROCESSDESCR;

			return TRUE;
		}
	}

//Error
	Log(("Del error: %s", ((DeleteData*)dt)->SkipAll ? "SkipAll" : "Ask"));

	if(((DeleteData*)dt)->SkipAll == FALSE)
	{
		rres = FtpConnectMessage(((DeleteData*)dt)->hConnect, MCannotDelete, CurName, -MCopySkip, MCopySkipAll);

		switch(rres)
		{
			/*skip*/     case 0:
				Log(("Skip"));
				return TRUE;
				/*skip all*/
			case 1:
				((DeleteData*)dt)->SkipAll = TRUE;
				Log(("SkipAll"));
				return TRUE;
			default:
				Log(("Other"));
				SetLastError(ERROR_CANCELLED);
				return FALSE;
		}
	}
	else
		return TRUE;
}
Ejemplo n.º 6
0
int FTP::MakeDirectory(String& Name,int OpMode)
{
	PROC(("FTP::MakeDirectory",NULL))
	FTPHost h;

	if(!ShowHosts && !hConnect)
		return FALSE;

	h.Init();

//Edit name
	if(!IS_SILENT(OpMode) && !IS_FLAG(OpMode,OPM_NODIALOG) &&
	        !EditDirectory(Name, ShowHosts ? h.HostDescr : NULL, TRUE))
		return -1;

//Correct name
	if(!Name[0])
		return -1;

//HOSTS
	if(ShowHosts)
	{
		if(Name.Cmp(".")  ||
		        Name.Cmp("..") ||
		        FTPHost::CheckHost(HostsPath, Name.c_str()))
		{
			SetLastError(ERROR_ALREADY_EXISTS);
			return FALSE;
		}

		char str[MAX_PATH];
		h.Folder = TRUE;
		StrCpy(h.Host, Name.c_str(), ARRAYSIZE(h.Host));
		h.MkINIFile(str,NULL,"");
		StrCpy(h.Host, str, ARRAYSIZE(h.Host));
		h.Write(HostsPath);
		SelectFile=Name;
		return TRUE;
	}

//FTP
	FP_Screen   scr;

	//Create directory
	do
	{
		//Try to create
		if(hConnect &&
		        FTPCreateDirectory(Name.c_str(), OpMode))
			return TRUE;

		//If conection alive - report error
		if(FtpCmdLineAlive(hConnect) ||
		        IS_SILENT(OpMode))
			return FALSE;

		//Try to reconnect
		if(!Reread())
			return FALSE;

		//Repeat operation
	}
	while(true);
}
Ejemplo n.º 7
0
BOOL FTP::FTPCreateDirectory(LPCSTR dir,int OpMode)
{
	String Command;
	int    len = (int)strlen(dir);

	if(!len)
		return FALSE;

	len--;
	Assert(hConnect && "FtpCreateDirectory");

	do
	{
		//Try relative path
		if(!isspace(dir[len]))
		{
			hConnect->CacheReset();
			Command.printf("mkdir \x1%s\x1", dir);

			if(hConnect->ProcessCommand(Command))
				break;
		}

		//Try relative path with end slash
		hConnect->CacheReset();
		Command.printf("mkdir \x1%s/\x1", dir);

		if(hConnect->ProcessCommand(Command))
			break;

		//Try absolute path
		if(!isspace(dir[len]))
		{
			Command.printf("mkdir \x1%s/%s\x1",
			               hConnect->SToOEM(hConnect->CurDir).c_str(), dir + (dir[0] == '/'));

			if(hConnect->ProcessCommand(Command))
				break;
		}

		//Try absolute path with end slash
		Command.printf("mkdir \x1%s/%s/\x1",
		               hConnect->SToOEM(hConnect->CurDir).c_str(), dir + (dir[0] == '/'));

		if(hConnect->ProcessCommand(Command))
			break;

		//Noone work
		return FALSE;
	}
	while(0);

	if(!IS_SILENT(OpMode))
	{
		int b = Command.Chr('\x1'),
		    e = Command.Chr('\x1', b+1);

		if(b == -1)
			SelectFile = "";
		else if(e == -1)
			SelectFile.Set(Command.c_str(), b+1, -1);
		else
			SelectFile.Set(Command.c_str(), b+1, e);
	}

	return TRUE;
}