コード例 #1
0
        public bool deleteSharedFileSynchronized(SharedFile file)
        {
            bool found = checkIfSharedFilePresentSynchronized(file);

            if (!found)
            {
                Logger.Debug("Shared file : " + file.filename + " not present in file system of the user " + this.metadata.clientId);
                return(false);
            }
            else
            {
                lock (this.privateLock) {                //lock the shared file list and then make a new list removing this file
                    Logger.Debug("Size of the share file list before removing is : " + this.sharedFiles.Count);
                    List <SharedFile> newfilelist = new List <SharedFile> ();
                    foreach (SharedFile f in this.sharedFiles)
                    {
                        if (f.filename.Equals(file.filename) && f.owner.Equals(file.owner))
                        {
                        }
                        else
                        {
                            newfilelist.Add(f);
                        }
                    }
                    this.sharedFiles = newfilelist;
                }
                Logger.Debug("Size of the share file list after removing is : " + this.sharedFiles.Count);
                return(true);
            }
        }
コード例 #2
0
 public SharedFile cloneObject()
 {
     SharedFile sf = new SharedFile ();
     sf.owner = this.owner;
     sf.filename = this.filename;
     return sf;
 }
コード例 #3
0
ファイル: SharedFile.cs プロジェクト: linmw/cloud-filesystem
        public SharedFile cloneObject()
        {
            SharedFile sf = new SharedFile();

            sf.owner    = this.owner;
            sf.filename = this.filename;
            return(sf);
        }
コード例 #4
0
        /* Synhronized method to checki if the file is already
         * shared with the user or not
         */
        private bool checkIfSharedFilePresentSynchronized(SharedFile file)
        {
            bool found = false;

            lock (this.privateLock){
                foreach (SharedFile f in this.sharedFiles)
                {
                    if (f.filename.Equals(file.filename) && f.owner.Equals(file.owner))
                    {
                        found = true;
                        break;
                    }
                }
            }
            return(found);
        }
コード例 #5
0
        /*	Synchronized method to add a shared file to the file system
         */
        public bool addSharedFileSynchronized(SharedFile file)
        {
            bool found = checkIfSharedFilePresentSynchronized(file);

            if (found)
            {
                Logger.Debug("Shared file : " + file.filename + " already present in file system of the user " + this.metadata.clientId);
                return(false);
            }
            else
            {
                lock (this.privateLock){                //lock the shared file list and add this file
                    Logger.Debug("Adding shared file :" + file.filename + " into the shared file list of user : " + this.metadata.clientId);
                    this.sharedFiles.Add(file);
                }
                return(true);
            }
        }
コード例 #6
0
 /* Synhronized method to checki if the file is already
  * shared with the user or not
  */
 private bool checkIfSharedFilePresentSynchronized(SharedFile file)
 {
     bool found = false;
     lock(this.privateLock){
         foreach(SharedFile f in this.sharedFiles){
             if( f.filename.Equals(file.filename) && f.owner.Equals(file.owner)){
                 found = true;
                 break;
             }
         }
     }
     return found;
 }
コード例 #7
0
        public bool deleteSharedFileSynchronized(SharedFile file)
        {
            bool found = checkIfSharedFilePresentSynchronized (file);
            if (! found) {
                Logger.Debug ("Shared file : " + file.filename + " not present in file system of the user " + this.metadata.clientId);
                return false;
            } else {
                lock (this.privateLock) {//lock the shared file list and then make a new list removing this file
                    Logger.Debug ("Size of the share file list before removing is : " + this.sharedFiles.Count);
                    List<SharedFile> newfilelist = new List<SharedFile> ();
                    foreach (SharedFile f in this.sharedFiles) {
                        if (f.filename.Equals (file.filename) && f.owner.Equals (file.owner)) {

                        } else {
                            newfilelist.Add (f);
                        }
                    }
                    this.sharedFiles = newfilelist;
                }
                Logger.Debug ("Size of the share file list after removing is : " + this.sharedFiles.Count);
                return true;
            }
        }
コード例 #8
0
 /*	Synchronized method to add a shared file to the file system
  */
 public bool addSharedFileSynchronized(SharedFile file)
 {
     bool found = checkIfSharedFilePresentSynchronized(file);
     if( found){
         Logger.Debug("Shared file : " + file.filename + " already present in file system of the user " + this.metadata.clientId);
         return false;
     }else{
         lock( this.privateLock){//lock the shared file list and add this file
             Logger.Debug("Adding shared file :" + file.filename + " into the shared file list of user : " + this.metadata.clientId);
             this.sharedFiles.Add(file);
         }
         return true;
     }
 }