Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/vncdll/winvnc/FileTransferItemInfo.cpp
Views: 11779
// Copyright (C) 2003 Dennis Syrovatsky. All Rights Reserved.1//2// This file is part of the VNC system.3//4// The VNC system is free software; you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation; either version 2 of the License, or7// (at your option) any later version.8//9// This program is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.13//14// You should have received a copy of the GNU General Public License15// along with this program; if not, write to the Free Software16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,17// USA.18//19// TightVNC distribution homepage on the Web: http://www.tightvnc.com/20//21// If the source code for the VNC system is not available from the place22// whence you received this file, check http://www.uk.research.att.com/vnc or contact23// the authors on [email protected] for information on obtaining it.2425#include "FileTransferItemInfo.h"26#include "stdlib.h"27#include "stdio.h"28#include "string.h"2930//////////////////////////////////////////////////////////////////////31// Construction/Destruction32//////////////////////////////////////////////////////////////////////3334FileTransferItemInfo::FileTransferItemInfo()35{36m_NumEntries = 0;37m_pEntries = NULL;38}3940FileTransferItemInfo::~FileTransferItemInfo()41{42Free();43}4445void FileTransferItemInfo::Add(char *Name, unsigned int Size, unsigned int Data)46{47FTITEMINFO *pTemporary = new FTITEMINFO[m_NumEntries + 1];48if (m_NumEntries != 0)49memcpy(pTemporary, m_pEntries, m_NumEntries * sizeof(FTITEMINFO));50strcpy(pTemporary[m_NumEntries].Name, Name);51pTemporary[m_NumEntries].Size = Size;52pTemporary[m_NumEntries].Data = Data;53if (m_pEntries != NULL) {54delete [] m_pEntries;55m_pEntries = NULL;56}57m_pEntries = pTemporary;58pTemporary = NULL;59m_NumEntries++;60}6162void FileTransferItemInfo::Free()63{64if (m_pEntries != NULL) {65delete [] m_pEntries;66m_pEntries = NULL;67}68m_NumEntries = 0;69}7071char * FileTransferItemInfo::GetNameAt(int Number)72{73if ((Number >= 0) && (Number <= m_NumEntries))74return m_pEntries[Number].Name;75return NULL;76}7778unsigned int FileTransferItemInfo::GetSizeAt(int Number)79{80if ((Number >= 0) && (Number <= m_NumEntries))81return m_pEntries[Number].Size;82return NULL;83}8485unsigned int FileTransferItemInfo::GetDataAt(int Number)86{87if ((Number >= 0) && (Number <= m_NumEntries))88return m_pEntries[Number].Data;89return NULL;90}9192int FileTransferItemInfo::GetNumEntries()93{94return m_NumEntries;95}9697int FileTransferItemInfo::GetSummaryNamesLength()98{99size_t sumLen = 0;100for (int i = 0; i < m_NumEntries; i++)101sumLen += strlen(m_pEntries[i].Name);102return (int)sumLen;103}104105106