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); } }
public SharedFile cloneObject() { SharedFile sf = new SharedFile (); sf.owner = this.owner; sf.filename = this.filename; return sf; }
public SharedFile cloneObject() { SharedFile sf = new SharedFile(); sf.owner = this.owner; sf.filename = this.filename; return(sf); }
/* 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); }
/* 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); } }
/* 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; }
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; } }
/* 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; } }