Beispiel #1
0
        void MoveDir(SrcDstInfo info)
        {
            string          command   = "SELECT name, path FROM directorys_info WHERE id = " + info.id + ";";
            MySqlCommand    commander = new MySqlCommand(command, connection);
            MySqlDataReader reader    = commander.ExecuteReader();

            if (!reader.Read())
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string        dirName = reader["name"].ToString();
            DirectoryInfo dir     = new DirectoryInfo(reader["path"].ToString());

            reader.Close();
            if (!dir.Exists)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            command   = "SELECT path FROM directorys_info WHERE id = " + info.dstDir + ";";
            commander = new MySqlCommand(command, connection);
            var dstDir = commander.ExecuteScalar();

            if (dstDir == null)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string newDir = dstDir.ToString() + dir.Name;

            dir.MoveTo(newDir);

            newDir = RemakePath(newDir, true);
            RefreshPath(info.id, newDir);

            int    count      = 1;
            string newDirName = dirName;

            while (IsInSameName(newDirName, info.dstDir, true))
            {
                newDirName = dirName + "(" + count++ + ")";
            }
            command   = "UPDATE directorys_info SET name = '" + newDirName + "', parent_id = " + info.dstDir + ", path = '" + newDir + "' WHERE id = " + info.id + ";";
            commander = new MySqlCommand(command, connection);
            if (commander.ExecuteNonQuery() != 1)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }
            socket.CryptoSend(null, PacketType.OK);

            UpdateModDate(info.srcDir);
            UpdateModDate(info.dstDir);
            return;
        }
Beispiel #2
0
        void MoveFile(SrcDstInfo info)
        {
            string          command   = "SELECT name, path FROM files_info WHERE id = " + info.id + ";";
            MySqlCommand    commander = new MySqlCommand(command, connection);
            MySqlDataReader reader    = commander.ExecuteReader();

            if (!reader.Read())
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string   fileName = reader["name"].ToString();
            FileInfo file     = new FileInfo(reader["path"].ToString());

            reader.Close();
            if (!file.Exists)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            command   = "SELECT path FROM directorys_info WHERE id = " + info.dstDir + ";";
            commander = new MySqlCommand(command, connection);
            var result = commander.ExecuteScalar();

            if (result == null)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string newFile = result.ToString() + file.Name;

            file.MoveTo(newFile);
            newFile = RemakePath(newFile, false);

            int    count       = 1;
            string newFileName = fileName;

            while (IsInSameName(newFileName, info.dstDir, false))
            {
                newFileName = fileName + "(" + count++ + ")";
            }

            command   = "UPDATE files_info SET name = '" + newFileName + "', dir_id = " + info.dstDir + ", path = '" + newFile + "' WHERE id = " + info.id + ";";
            commander = new MySqlCommand(command, connection);
            if (commander.ExecuteNonQuery() != 1)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }
            socket.CryptoSend(null, PacketType.OK);

            UpdateModDate(info.srcDir);
            UpdateModDate(info.dstDir);
            return;
        }
Beispiel #3
0
        void CopyDir(SrcDstInfo info)
        {
            string          command   = "SELECT name, path FROM directorys_info WHERE id = " + info.id + ";";
            MySqlCommand    commander = new MySqlCommand(command, connection);
            MySqlDataReader reader    = commander.ExecuteReader();

            if (!reader.Read())
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string        dirName = reader["name"].ToString();
            DirectoryInfo dir     = new DirectoryInfo(reader["path"].ToString());

            reader.Close();
            if (!dir.Exists)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            command   = "SELECT path FROM directorys_info WHERE id = " + info.dstDir + ";";
            commander = new MySqlCommand(command, connection);
            var dstDir = commander.ExecuteScalar();

            if (dstDir == null)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            uint newDirID = MakeNewDir(dirName, info.dstDir);

            if (newDirID == 0)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string        newDirPath = dstDir.ToString() + newDirID;
            DirectoryInfo newDir     = new DirectoryInfo(newDirPath);

            newDir.Create();
            DirCopyTo(info.id, newDirID);

            //RefreshPath(info.id, newDir);


            socket.CryptoSend(null, PacketType.OK);

            UpdateModDate(info.dstDir);
            return;
        }
Beispiel #4
0
        void CopyFile(SrcDstInfo info)
        {
            string          command   = "SELECT name, path FROM files_info WHERE id = " + info.id + ";";
            MySqlCommand    commander = new MySqlCommand(command, connection);
            MySqlDataReader reader    = commander.ExecuteReader();

            if (!reader.Read())
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string   fileName = reader["name"].ToString();
            FileInfo file     = new FileInfo(reader["path"].ToString());

            reader.Close();
            if (!file.Exists)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            uint newFileID = MakeNewFile(fileName, info.dstDir, (uint)file.Length);

            if (newFileID == 0)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            command   = "SELECT path FROM directorys_info WHERE id = " + info.dstDir + ";";
            commander = new MySqlCommand(command, connection);
            var dstDir = commander.ExecuteScalar();

            if (dstDir == null)
            {
                socket.CryptoSend(null, PacketType.Fail);
                return;
            }

            string newFile = dstDir.ToString() + newFileID + ".blind";

            file.CopyTo(newFile);

            socket.CryptoSend(null, PacketType.OK);

            UpdateModDate(info.dstDir);
            return;
        }