Beispiel #1
0
        public void GetNearestCSharpProject_returns_null_for_no_project()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory + @"\..\..\..\..";
            var file = FileSupport.GetNearestCSharpProject(path);

            Assert.IsNull(file);
        }
Beispiel #2
0
        public void GetNearestCSharpProject_finds_project_from_project_path()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory + @"\..\..\UtilitiesTests.csproj";
            var file = FileSupport.GetNearestCSharpProject(path);

            Assert.IsTrue(file.EndsWith(@"\UtilitiesTests.csproj"));
        }
Beispiel #3
0
        public void GetNearestSolution_finds_solution_from_solution_path()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory + @"\..\..\..\RoslynDom.sln";
            var file = FileSupport.GetNearestSolution(path);

            Assert.IsTrue(file.EndsWith(@"\RoslynDom.sln"));
        }
Beispiel #4
0
        public void GetNearestSolution_returns_null_for_no_solution()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory + @"\..\..\..\..\..";
            var file = FileSupport.GetNearestSolution(path);

            Assert.IsNull(file);
        }
        protected override void ProcessRecord()
        {
            ResumeSupport = new Resume.ResumeSupport();
            FileSupport   = new FileSupport(MarkFileStatus);

            if (ResumeSupport.IsPending)
            {
                Logger.Instance.Info("Last command wasn't successful due to discconnection.");

                Console.Write("Last command wasn't successful due to discconnection, enter 'y' to complete or any other key to ignore: ");
                String userOption = Console.ReadLine();

                if (userOption.ToLower().Equals("y"))
                {
                    Logger.Instance.Info("Copying those files which were missed due to discconnection with following parameters. Source Path:{0} Destination:{1} Forced:{2} Details:{3}",
                                         String.Join(",", ResumeSupport.GetPath), ResumeSupport.GetDestination, ResumeSupport.GetForce, ResumeSupport.GetDetails);

                    StartCopying(ResumeSupport.GetPath, ResumeSupport.GetDestination, ResumeSupport.GetForce, ResumeSupport.GetDetails);

                    Logger.Instance.Info("Copying operation completed for missing files");
                    ResumeSupport.End();
                    Console.Write("Last command completed, starting current operation");
                }
            }

            Logger.Instance.Info(String.Format("Starting Copy Operation with following parameters. Source Path:{0} Destination:{1} Forced:{2} Details:{3}",
                                               String.Join(",", Path), Destination, Force, Details));
            ResumeSupport.Start(Path, Destination, Force, Details);

            StartCopying(Path, Destination, Force, Details);

            ResumeSupport.End();
            Logger.Instance.Info("Command executed successfully");
            WriteObject("Files copied successfully");
        }
Beispiel #6
0
        public void GetNearestFilesOfType_adds_period_when_needed()
        {
            var path  = AppDomain.CurrentDomain.BaseDirectory;
            var files = FileSupport.GetNearestFilesOfType(path, "dll");

            Assert.IsTrue(files.Count() > 0);
        }
Beispiel #7
0
        internal static string MaybeCreateTempFile(bool removeAfterClass = true)
        {
            string result = null;
            Stream temp   = null;

            if (LuceneTestCase.TestLineDocsFile == LuceneTestCase.DEFAULT_LINE_DOCS_FILE) // Always GZipped
            {
                temp = typeof(LineFileDocs).FindAndGetManifestResourceStream(LuceneTestCase.TestLineDocsFile);
            }
            else if (LuceneTestCase.TestLineDocsFile.EndsWith(".gz", StringComparison.Ordinal))
            {
                temp = new FileStream(LuceneTestCase.TestLineDocsFile, FileMode.Open, FileAccess.Read, FileShare.Read);
            }
            if (null != temp)
            {
                var file = removeAfterClass
                    ? LuceneTestCase.CreateTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX)
                    : FileSupport.CreateTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX);
                result = file.FullName;
                using (var gzs = new GZipStream(temp, CompressionMode.Decompress, leaveOpen: false))
                    using (Stream output = new FileStream(result, FileMode.Open, FileAccess.Write, FileShare.Read))
                    {
                        gzs.CopyTo(output);
                    }
            }
            return(result);
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommonSteps"/> class.
 /// Привязка общих шагов к работе с переменным через контекст.
 /// </summary>
 /// <param name="variableContext">Контекст для работы с переменными.</param>
 /// <param name="fileSupport">Контекст для работы с файлами.</param>
 /// <param name="consoleOutputHelper">Capturing Output.</param>
 public CommonSteps(VariableContext variableContext, FileSupport fileSupport,
                    ITestOutputHelper consoleOutputHelper)
 {
     this.variableContext     = variableContext;
     this.fileSupport         = fileSupport;
     this.consoleOutputHelper = consoleOutputHelper;
 }
Beispiel #9
0
        public void GetMatchingFiles_doesnt_crash_on_no_files()
        {
            var path = AppDomain.CurrentDomain.BaseDirectory;

            Assert.AreEqual(0, FileSupport.GetMatchingFiles("*.xadman", FileSupport.ProjectPath(path), true).Count());
            Assert.AreEqual(0, FileSupport.GetMatchingFiles("*.xadman", FileSupport.ProjectPath(path), false).Count());
        }
Beispiel #10
0
        public void ProjectPath_finds_project_in_higher_directory()
        {
            // This test expects current file structure
            var path = AppDomain.CurrentDomain.BaseDirectory;

            Assert.IsNotNull(FileSupport.ProjectPath(path));
        }
        public void LoadInitialConditions()
        {
            string pressureFile    = string.Format("P{0:d2}.thd", _levelType);
            string temperatureFile = string.Format("T{0:d2}.thd", _levelType);
            string humidityFile    = string.Format("H{0:d2}.thd", _levelType);

            string filePath = Path.Combine(SimulationData.WorkFolder, temperatureFile);

            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            DenseMatrix t = FileSupport.LoadMatrixFromFile(filePath);

            filePath = Path.Combine(SimulationData.WorkFolder, pressureFile);
            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            DenseMatrix p = FileSupport.LoadMatrixFromFile(filePath);

            filePath = Path.Combine(SimulationData.WorkFolder, humidityFile);
            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            DenseMatrix h = FileSupport.LoadMatrixFromFile(filePath);

            H = h.EQ();
            P = p.EQ();
            T = t.EQ();
        }
        public void Can_load_prop_changed_code_from_file()
        {
            var str  = FileSupport.GetFileContents(@"..\..\PropertyChanged1.cfcs");
            var root = RDom.CSharp.Load(str);

            Assert.IsNotNull(root);
        }
 public void IsReadableTest()
 {
     Assert.True(FileSupport.IsFileReadable(_fixture.UnwritableFilePath));
     Assert.True(FileSupport.IsFileReadable(_fixture.WritableFilePath));
     Assert.False(FileSupport.IsFileReadable(_fixture.UnreadableFilePath));
     Assert.False(FileSupport.IsFileReadable(_fixture.InvalidFilePath));
 }
Beispiel #14
0
        /// <summary>
        /// Sort a single partition in-memory. </summary>
        internal FileInfo SortPartition(int len)
        {
            var      data     = this.Buffer;
            FileInfo tempFile = FileSupport.CreateTempFile("sort", "partition", DefaultTempDir());

            long start = Environment.TickCount;

            sortInfo.SortTime += (Environment.TickCount - start);

            using (var @out = new ByteSequencesWriter(tempFile))
            {
                BytesRef spare;

                BytesRefIterator iter = Buffer.Iterator(comparator);
                while ((spare = iter.Next()) != null)
                {
                    Debug.Assert(spare.Length <= ushort.MaxValue);
                    @out.Write(spare);
                }
            }

            // Clean up the buffer for the next partition.
            data.Clear();
            return(tempFile);
        }
Beispiel #15
0
        /// <summary>
        /// Sort a single partition in-memory. </summary>
        private FileInfo SortPartition(/*int len*/) // LUCENENET NOTE: made private, since protected is not valid in a sealed class. Also eliminated unused parameter.
        {
            var      data     = this.buffer;
            FileInfo tempFile = FileSupport.CreateTempFile("sort", "partition", DefaultTempDir());

            long start = J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond;                     // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results

            sortInfo.SortTime += ((J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond) - start); // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results

            using (var @out = new ByteSequencesWriter(tempFile))
            {
                IBytesRefEnumerator iter = buffer.GetEnumerator(comparer);
                while (iter.MoveNext())
                {
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(iter.Current.Length <= ushort.MaxValue);
                    }
                    @out.Write(iter.Current);
                }
            }

            // Clean up the buffer for the next partition.
            data.Clear();
            return(tempFile);
        }
 public void IsWritableTest()
 {
     Assert.False(FileSupport.IsFileWritable(_fixture.UnwritableFilePath));
     Assert.True(FileSupport.IsFileWritable(_fixture.WritableFilePath));
     Assert.False(FileSupport.IsFileWritable(_fixture.NonExistentFilePath));
     Assert.False(FileSupport.IsFileWritable(_fixture.InvalidFilePath));
 }
        public override CommandResult Validate(CommandArg arg)
        {
            CommandResult result = base.Validate(arg);

            if (result.Succeeded)
            {
                string path = arg.Value;
                if (!Path.IsPathFullyQualified(path))
                {
                    try
                    {
                        path = Path.Combine(GeneralParameters.Instance.WorkingFolder, path);
                    }
                    catch (Exception ex)
                    {
                        result.Append(new CommandResult(false, "Invalid path:", ex));
                    }
                }
                if (result.Succeeded)
                {
                    if (!FileSupport.IsFolderReadable(path))
                    {
                        return(new CommandResult(false, $"Folder '{path}' does not exist or is not readable"));
                    }
                    arg.ResolvedValue = path;
                }
            }
            return(result);
        }
        public void Run(DateTime dtInit)
        {
            if (SimulationData.AvailableSnapshots.Count > 0)
            {
                int rangeSize = _statsRangeLength;

                int totalRanges = (int)Math.Round((float)SimulationData.AvailableSnapshots.Count / (float)rangeSize);

                SimDateTime firstSnapshotStart = SimulationData.AvailableSnapshots[0];

                for (int id = 0; id < totalRanges; id++)
                {
                    _doneEvents.Add(new ManualResetEvent(false));

                    ThreadPool.QueueUserWorkItem((c) => ProcessSimRange(dtInit, firstSnapshotStart, rangeSize, (int)c), id);
                    //ProcessSimRange(dtInit, firstSnapshotStart, rangeSize, id);
                }

                ManualResetEvent.WaitAll(_doneEvents.ToArray());

                TimeSpan tsDiff = DateTime.Now - dtInit;
                Console.WriteLine($"  -> Statistics completed after {(int)tsDiff.TotalMilliseconds} msec.");
            }

            FileSupport.WaitForPendingWriteOperations();
        }
        public void SaveStats(string title, string category)
        {
            FileSupport.SaveAsStats(TE, title, "T_TE_MAP", category);
            FileSupport.SaveAsStats(TW, title, "T_TW_MAP", category);
            FileSupport.SaveAsStats(TL, title, "T_TL_MAP", category);
            FileSupport.SaveAsStats(TS, title, "T_TS_MAP", category);

            FileSupport.SaveAsStats(SNOW, title, "N_00_MAP", category);
            FileSupport.SaveAsStats(RAIN, title, "R_00_MAP", category);

            FileSupport.SaveAsStats(BLIZZARD, title, "B_00_MAP", category);
            FileSupport.SaveAsStats(ALBEDO, title, "A_00_MAP", category);

            FileSupport.SaveAsStats(Precip, title, "C_00_MAP", category);
            FileSupport.SaveAsStats(TLow, title, "T_SL_MAP", category);
            FileSupport.SaveAsStats(THigh, title, "T_SH_MAP", category);
            FileSupport.SaveAsStats(LIDX, title, "L_00_MAP", category);

            FileSupport.SaveAsStats(FOG, title, "F_SI_MAP", category);

            FileSupport.SaveAsStats(TNormLow, title, "T_NL_MAP", category);
            FileSupport.SaveAsStats(TNormHigh, title, "T_NH_MAP", category);

            FileSupport.SaveAsStats((TLow - TNormLow), title, "T_DL_MAP", category);
            FileSupport.SaveAsStats((THigh - TNormHigh), title, "T_DH_MAP", category);

            FileSupport.SaveAsStats(0.5f * (TLow - TNormLow + THigh - TNormHigh), title, "T_DA_MAP", category);
        }
Beispiel #20
0
        private static int?LoadFileLockViolationHResult()
        {
            if (Constants.WINDOWS)
            {
                return(WIN_HRESULT_FILE_LOCK_VIOLATION);
            }

            // Skip provoking the exception unless we know we will use the value
            if (IS_FILESTREAM_LOCKING_PLATFORM)
            {
                return(FileSupport.GetFileIOExceptionHResult(provokeException: (fileName) =>
                {
                    using (var lockStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite))
                    {
                        lockStream.Lock(0, 1); // Create an exclusive lock
                        using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Write, FileShare.ReadWrite))
                        {
                            // try to find out if the file is locked by writing a byte. Note that we need to flush the stream to find out.
                            stream.WriteByte(0);
                            stream.Flush();   // this *may* throw an IOException if the file is locked, but...
                                              // ... closing the stream is the real test
                        }
                    }
                }));
            }

            return(null);
        }
        private void InitGeographicalParams()
        {
            // ------------
            string filePath = ".\\ElevationMap.thd";

            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            Height = FileSupport.LoadMatrixFromFile(filePath);

            // ------------
            filePath = ".\\LandWaterMask.thd";
            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            var wlMask = FileSupport.LoadMatrixFromFile(filePath);
            var he     = Height.EQ(8);

            WL.Assign((r, c) =>
            {
                var sgn = 0f;

                sgn = Math.Sign(wlMask[r, c]);
                if (sgn == 1)
                {
                    return(1);
                }

                if (he[r, c] >= 50f)
                {
                    return(0);
                }

                return(1);
            });


            // ------------
            filePath = ".\\ADJ_LR.thd";
            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            this.ADJ_LR = FileSupport.LoadMatrixFromFile(filePath);

            // ------------
            filePath = ".\\albedo.thd";
            if (File.Exists(filePath) == false)
            {
                throw new FileNotFoundException();
            }

            this.ALBEDO     = FileSupport.LoadMatrixFromFile(filePath);
            this.DEF_ALBEDO = FileSupport.LoadMatrixFromFile(filePath);
        }
        public void Save(string title)
        {
            FileSupport.Save(TE, title, "T_TE_MAP");
            FileSupport.Save(TW, title, "T_TW_MAP");
            FileSupport.Save(TL, title, "T_TL_MAP");
            FileSupport.Save(TS, title, "T_TS_MAP");

            FileSupport.Save(SNOW, title, "N_00_MAP");
            FileSupport.Save(RAIN, title, "R_00_MAP");

            FileSupport.Save(BLIZZARD, title, "B_00_MAP");
            FileSupport.Save(ALBEDO, title, "A_00_MAP");

            FileSupport.Save(Precip, title, "C_00_MAP");
            FileSupport.Save(TLow, title, "T_SL_MAP");
            FileSupport.Save(THigh, title, "T_SH_MAP");
            FileSupport.Save(LIDX, title, "L_00_MAP");

            FileSupport.Save(FOG, title, "F_SI_MAP");

            FileSupport.Save(TNormLow, title, "T_NL_MAP");
            FileSupport.Save(TNormHigh, title, "T_NH_MAP");

            FileSupport.Save(TLow - TNormLow, title, "T_DL_MAP");
            FileSupport.Save(THigh - TNormHigh, title, "T_DH_MAP");
            FileSupport.Save(0.5f * (TLow - TNormLow + THigh - TNormHigh).EQ(), title, "T_DA_MAP");

            FileSupport.Save((1000 * WL - MatrixFactory.Init(500)), title, "E_00_MAP");
        }
Beispiel #23
0
        /// <summary>
        /// Sort a single partition in-memory. </summary>
        private FileInfo SortPartition(int len) // LUCENENET NOTE: made private, since protected is not valid in a sealed class
        {
            var      data     = this.buffer;
            FileInfo tempFile = FileSupport.CreateTempFile("sort", "partition", DefaultTempDir());

            long start = Environment.TickCount;

            sortInfo.SortTime += (Environment.TickCount - start);

            using (var @out = new ByteSequencesWriter(tempFile))
            {
                BytesRef spare;

                IBytesRefIterator iter = buffer.GetIterator(comparer);
                while ((spare = iter.Next()) != null)
                {
                    Debug.Assert(spare.Length <= ushort.MaxValue);
                    @out.Write(spare);
                }
            }

            // Clean up the buffer for the next partition.
            data.Clear();
            return(tempFile);
        }
Beispiel #24
0
 public ProgressBar(FileSupport sfItem)
 {
     Finished      = false;
     CurrentFile   = null;
     CurrentPct    = 0;
     CopySfItemObj = sfItem;
 }
Beispiel #25
0
        public static FolderStatus Validate(string path)
        {
            FolderStatus status = FolderStatus.Valid;

            if (String.IsNullOrEmpty(path))
            {
                status |= FolderStatus.NullPath;
            }
            else if (!FileSupport.IsValidPath(path))
            {
                status |= FolderStatus.InvalidPath;
            }
            else if (!System.IO.Path.IsPathFullyQualified(path))
            {
                status |= FolderStatus.NotFullyQualified;
            }
            else if (!Directory.Exists(path))
            {
                status |= FolderStatus.Nonextant;
            }
            else if (!FileSupport.IsFolderReadable(path))
            {
                status |= FolderStatus.Unreadable;
            }
            return(status);
        }
Beispiel #26
0
        /// <summary>
        /// Sort a single partition in-memory. </summary>
        private FileInfo SortPartition(/*int len*/) // LUCENENET NOTE: made private, since protected is not valid in a sealed class. Also eliminated unused parameter.
        {
            var      data     = this.buffer;
            FileInfo tempFile = FileSupport.CreateTempFile("sort", "partition", DefaultTempDir());

            long start = Environment.TickCount;

            sortInfo.SortTime += (Environment.TickCount - start);

            using (var @out = new ByteSequencesWriter(tempFile))
            {
                IBytesRefEnumerator iter = buffer.GetEnumerator(comparer);
                while (iter.MoveNext())
                {
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(iter.Current.Length <= ushort.MaxValue);
                    }
                    @out.Write(iter.Current);
                }
            }

            // Clean up the buffer for the next partition.
            data.Clear();
            return(tempFile);
        }
Beispiel #27
0
        public void ProjectPath_finds_project_in_parent_directory()
        {
            // This test expects current file structure
            var path = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);

            Assert.IsNotNull(FileSupport.ProjectPath(path));
        }
Beispiel #28
0
        public void Can_load_code_eventsource_from_file()
        {
            var str  = FileSupport.GetFileContents(@"..\..\EventSource1.cfcs");
            var root = RDom.CSharp.Load(str);

            Assert.IsNotNull(root);
        }
Beispiel #29
0
        public Atmosphere(EarthModel earth, bool loadFromStateFiles, float defaultValue = 0)
        {
            this.Earth = earth;

            SeaLevel = new SeaLevel(earth, loadFromStateFiles, defaultValue);
            MidLevel = new MidLevel(earth, loadFromStateFiles, defaultValue);
            TopLevel = new TopLevel(earth, loadFromStateFiles, defaultValue);
            JetLevel = new JetLevel(earth, loadFromStateFiles, defaultValue);

            if (loadFromStateFiles == false)
            {
                if (defaultValue == 0)
                {
                    TopLevel.LoadInitialConditions();

                    MidLevel.LoadInitialConditions();
                    CalculateAirMassType();

                    SeaLevel.LoadInitialConditions();
                }
                else
                {
                    AirMass = MatrixFactory.Init(defaultValue);
                }
            }
            else
            {
                AirMass = FileSupport.Load(Earth.UTC.Title, "M_00_MAP");
            }
        }
Beispiel #30
0
        public void GetFileContents_returns_contents()
        {
            var path    = AppDomain.CurrentDomain.BaseDirectory;
            var file    = Path.Combine(path, @"..\..\normal.kadcs");
            var results = FileSupport.GetFileContents(file);

            Assert.IsTrue(results.StartsWith("using KadMan.Common;"));
        }
 public DownloadAction(FileSupport fileSupport, Client.ShareFileClient client, int downloadId, Models.File child, FileSystemInfo target, ActionType type)
 {
     this.child = child;
     this.client = client;
     this.downloadId = downloadId;
     this.target = target;
     this.actionType = type;
     this.fileSupportDelegate = fileSupport;
 }
        protected override void ProcessRecord()
        {
            ResumeSupport = new Resume.ResumeSupport();
            FileSupport = new FileSupport(MarkFileStatus);

            if (Resume)
            {
                if (ResumeSupport.IsPending)
                {
                    Logger.Instance.Info("Last command wasn't successful due to discconnection.");

                    WriteObject("Last command wasn't successful due to discconnection, enter 'y' to complete or any other key to ignore: ");
                    Collection<PSObject> result = InvokeCommand.InvokeScript("Read-Host");
                    string userOption = result != null && result.Count > 0 ? result[0].ToString() : string.Empty;

                    if (userOption.ToLower().Equals("y"))
                    {
                        Logger.Instance.Info("Copying those files which were missed due to discconnection with following parameters. Source Path:{0} Destination:{1} Forced:{2} Details:{3}",
                            String.Join(",", ResumeSupport.GetPath), ResumeSupport.GetDestination, ResumeSupport.GetForce, ResumeSupport.GetDetails);

                        StartCopying(ResumeSupport.GetPath, ResumeSupport.GetDestination, ResumeSupport.GetForce, ResumeSupport.GetDetails);

                        Logger.Instance.Info("Copying operation completed for missing files");
                        ResumeSupport.End();
                        WriteObject("Last command completed, starting current operation");
                    }
                }
            }
            else
            {
                ResumeSupport.UnmarkResumeFlag();
            }

            Logger.Instance.Info(String.Format("Starting Copy Operation with following parameters. Source Path:{0} Destination:{1} Forced:{2} Details:{3}",
                String.Join(",", Path), Destination, Force, Details));

            if (Resume) ResumeSupport.Start(Path, Destination, Force, Details);
            
            StartCopying(Path, Destination.Trim(), Force, Details);
            Thread.Sleep(100);

            if (Resume) ResumeSupport.End();

            WriteObject("Files copied successfully");
        }
        /// <summary>
        /// Sync-SFItem Command is invoked
        /// </summary>
        protected override void ProcessRecord()
        {
            FileSupport = new FileSupport(TestMethod);
            ProviderInfo providerInfo;
            PSDriveInfo driveInfo;

            if (Upload && Download)
            {
                throw new PSArgumentException("Provide only one switch to Upload or Download the files");
            }

            if (!string.IsNullOrEmpty(ShareFilePath))
            {
                if (!Upload && !Download)
                {
                    throw new PSArgumentException("Upload or Download switch must be specified");
                }

                if (string.IsNullOrEmpty(LocalPath) || string.IsNullOrEmpty(LocalPath.Trim()))
                {
                    // use current user directory location if Local path is not specified in arguments
                    LocalPath = this.SessionState.Path.CurrentFileSystemLocation.Path;
                }

                if (Synchronize)
                {
                    Recursive = true;
                }

                if (Move)
                {
                    Recursive = true;
                }

                ShareFilePath = ShareFilePath.Trim();
                LocalPath = LocalPath.Trim();

                ActionType actionType = OverWrite ? ActionType.Force : (Synchronize ? ActionType.Sync : ActionType.None);

                int transactionId = new Random((int)DateTime.Now.Ticks).Next();

                // if current user directory is local storage and ShareFile path provided withouth drive letter then append the drive letter with sharefile location
                if (this.SessionState.Path.CurrentLocation.Provider.ImplementingType != typeof(ShareFileProvider) && ShareFilePath.IndexOf(":") < 1)
                {
                    Collection<PSDriveInfo> providerDrives = this.SessionState.Drive.GetAll();// ForProvider("ShareFile");
                    foreach (PSDriveInfo driveObj in providerDrives)
                    {
                        if (driveObj.Provider.ImplementingType == typeof(ShareFileProvider))
                        {
                            if (ShareFilePath.StartsWith("/") || ShareFilePath.StartsWith(@"\"))
                            {
                                ShareFilePath = ShareFilePath.Substring(1);
                            }
                            string sfDrive = String.Format("{0}:/", driveObj.Name);
                            ShareFilePath = Path.Combine(sfDrive, ShareFilePath);
                            break;
                        }
                    }
                }

                var sourcePath = Upload ? LocalPath : ShareFilePath;

                // it will resolve paths if wildcards are used e.g. "D:\\*.txt" then get paths of all files with txt extension from D:\\ location
                var resolvedPaths = this.GetResolvedProviderPathFromPSPath(sourcePath, out providerInfo);

                if (Download)
                {
                    this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(sourcePath, out providerInfo, out driveInfo);

                    var client = ((ShareFileDriveInfo)driveInfo).Client;

                    StartDownload(client, driveInfo, resolvedPaths, actionType);
                }
                else
                {
                    var unresolvedPath = this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(ShareFilePath, out providerInfo, out driveInfo);

                    var client = ((ShareFileDriveInfo)driveInfo).Client;
                    Item targetItem = ShareFileProvider.GetShareFileItem((ShareFileDriveInfo)driveInfo, unresolvedPath);

                    if (targetItem == null && !unresolvedPath.StartsWith(String.Format(@"\{0}\", Utility.DefaultSharefileFolder)))
                    {
                        string updatedPath = String.Format(@"\{0}\{1}", Utility.DefaultSharefileFolder, unresolvedPath);
                        targetItem = ShareFileProvider.GetShareFileItem((ShareFileDriveInfo)driveInfo, updatedPath, null, null);
                    }
                    //else if (targetItem == null)
                    //{
                    //    targetItem = ShareFileProvider.GetShareFileItem((ShareFileDriveInfo)driveInfo, ShareFilePath, null, null);
                    //}

                    if (targetItem == null)
                    {
                        throw new FileNotFoundException("Destination path not found on ShareFile server.");
                    }

                    // if user didn't specify the Sharefile HomeFolder in path then appending in path
                    // e.g. if user tries sf:/Folder1 as sharefile target then resolve this path to sf:/My Files & Folders/Folder1
                    if ((targetItem as Folder).Info.IsAccountRoot == true)
                    {
                        string updatedPath = String.Format(@"\{0}\{1}", Utility.DefaultSharefileFolder, unresolvedPath);
                        targetItem = ShareFileProvider.GetShareFileItem((ShareFileDriveInfo)driveInfo, updatedPath, null, null);
                    }

                    StartUpload(client, transactionId, targetItem, resolvedPaths, actionType);
                }

                WriteObject("Sync operation successfully completed.");
            }

            if (Help)
            {
                WriteObject("SFCLI version " + Resources.Version);
            }
        }