Statistics
| Branch: | Revision:

root / trunk / Pithos.Core / Agents / MovedEventArgs.cs @ 78ebfd2d

History | View | Annotate | Download (3.1 kB)

1 78ebfd2d Panagiotis Kanavos
// -----------------------------------------------------------------------
2 78ebfd2d Panagiotis Kanavos
// <copyright file="FileInfoExtensions.cs" company="GRNET">
3 78ebfd2d Panagiotis Kanavos
// Copyright 2011 GRNET S.A. All rights reserved.
4 78ebfd2d Panagiotis Kanavos
// 
5 78ebfd2d Panagiotis Kanavos
// Redistribution and use in source and binary forms, with or
6 78ebfd2d Panagiotis Kanavos
// without modification, are permitted provided that the following
7 78ebfd2d Panagiotis Kanavos
// conditions are met:
8 78ebfd2d Panagiotis Kanavos
// 
9 78ebfd2d Panagiotis Kanavos
//   1. Redistributions of source code must retain the above
10 78ebfd2d Panagiotis Kanavos
//      copyright notice, this list of conditions and the following
11 78ebfd2d Panagiotis Kanavos
//      disclaimer.
12 78ebfd2d Panagiotis Kanavos
// 
13 78ebfd2d Panagiotis Kanavos
//   2. Redistributions in binary form must reproduce the above
14 78ebfd2d Panagiotis Kanavos
//      copyright notice, this list of conditions and the following
15 78ebfd2d Panagiotis Kanavos
//      disclaimer in the documentation and/or other materials
16 78ebfd2d Panagiotis Kanavos
//      provided with the distribution.
17 78ebfd2d Panagiotis Kanavos
// 
18 78ebfd2d Panagiotis Kanavos
// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
19 78ebfd2d Panagiotis Kanavos
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 78ebfd2d Panagiotis Kanavos
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 78ebfd2d Panagiotis Kanavos
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
22 78ebfd2d Panagiotis Kanavos
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 78ebfd2d Panagiotis Kanavos
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 78ebfd2d Panagiotis Kanavos
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 78ebfd2d Panagiotis Kanavos
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 78ebfd2d Panagiotis Kanavos
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 78ebfd2d Panagiotis Kanavos
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 78ebfd2d Panagiotis Kanavos
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 78ebfd2d Panagiotis Kanavos
// POSSIBILITY OF SUCH DAMAGE.
30 78ebfd2d Panagiotis Kanavos
// 
31 78ebfd2d Panagiotis Kanavos
// The views and conclusions contained in the software and
32 78ebfd2d Panagiotis Kanavos
// documentation are those of the authors and should not be
33 78ebfd2d Panagiotis Kanavos
// interpreted as representing official policies, either expressed
34 78ebfd2d Panagiotis Kanavos
// or implied, of GRNET S.A.
35 78ebfd2d Panagiotis Kanavos
// </copyright>
36 78ebfd2d Panagiotis Kanavos
// -----------------------------------------------------------------------
37 78ebfd2d Panagiotis Kanavos
38 78ebfd2d Panagiotis Kanavos
39 78ebfd2d Panagiotis Kanavos
using System.Diagnostics.Contracts;
40 78ebfd2d Panagiotis Kanavos
using System.IO;
41 78ebfd2d Panagiotis Kanavos
using System.Security.Permissions;
42 78ebfd2d Panagiotis Kanavos
using System;
43 78ebfd2d Panagiotis Kanavos
44 78ebfd2d Panagiotis Kanavos
namespace Pithos.Core.Agents
45 78ebfd2d Panagiotis Kanavos
{
46 78ebfd2d Panagiotis Kanavos
    
47 78ebfd2d Panagiotis Kanavos
48 78ebfd2d Panagiotis Kanavos
    public delegate void MovedEventHandler(object sender, MovedEventArgs e);
49 78ebfd2d Panagiotis Kanavos
50 78ebfd2d Panagiotis Kanavos
    public class MovedEventArgs : FileSystemEventArgs
51 78ebfd2d Panagiotis Kanavos
    {
52 78ebfd2d Panagiotis Kanavos
        private readonly string _oldName;
53 78ebfd2d Panagiotis Kanavos
        private readonly string _oldFullPath;
54 78ebfd2d Panagiotis Kanavos
55 78ebfd2d Panagiotis Kanavos
        public string OldFullPath
56 78ebfd2d Panagiotis Kanavos
        {
57 78ebfd2d Panagiotis Kanavos
            get
58 78ebfd2d Panagiotis Kanavos
            {
59 78ebfd2d Panagiotis Kanavos
                new FileIOPermission(FileIOPermissionAccess.Read, Path.GetPathRoot(_oldFullPath)).Demand();
60 78ebfd2d Panagiotis Kanavos
                return _oldFullPath;
61 78ebfd2d Panagiotis Kanavos
            }
62 78ebfd2d Panagiotis Kanavos
        }
63 78ebfd2d Panagiotis Kanavos
64 78ebfd2d Panagiotis Kanavos
        public string OldName
65 78ebfd2d Panagiotis Kanavos
        {
66 78ebfd2d Panagiotis Kanavos
            get { return _oldName; }
67 78ebfd2d Panagiotis Kanavos
        }
68 78ebfd2d Panagiotis Kanavos
69 78ebfd2d Panagiotis Kanavos
        public MovedEventArgs(string newDirectory, string newName, string oldDirectory, string oldName)
70 78ebfd2d Panagiotis Kanavos
            : base(WatcherChangeTypes.Renamed, newDirectory, newName)
71 78ebfd2d Panagiotis Kanavos
        {
72 78ebfd2d Panagiotis Kanavos
            if (String.IsNullOrWhiteSpace(oldDirectory))
73 78ebfd2d Panagiotis Kanavos
                throw new ArgumentNullException("oldDirectory");
74 78ebfd2d Panagiotis Kanavos
            if (String.IsNullOrWhiteSpace(oldName))
75 78ebfd2d Panagiotis Kanavos
                throw new ArgumentNullException("oldName");
76 78ebfd2d Panagiotis Kanavos
            Contract.EndContractBlock();
77 78ebfd2d Panagiotis Kanavos
78 78ebfd2d Panagiotis Kanavos
            _oldName = oldName;
79 78ebfd2d Panagiotis Kanavos
            _oldFullPath = Path.Combine(oldDirectory, oldName);
80 78ebfd2d Panagiotis Kanavos
        }
81 78ebfd2d Panagiotis Kanavos
    }
82 78ebfd2d Panagiotis Kanavos
}