Set() public static method

Sets a flag for a file in an external flag file.
is not a relative path. There was an error writing the flag file. You have insufficient rights to write the flag file.
public static Set ( [ path, [ relativePath ) : void
path [ The full path to the flag file, named or .
relativePath [ The path of the file to set relative to .
return void
Esempio n. 1
0
        public void TestSet()
        {
            using (var flagFile = new TemporaryFile("0install-unit-tests"))
            {
                FlagUtils.Set(flagFile, Path.Combine("dir1", "file1"));
                File.ReadAllText(flagFile).Should().Be("/dir1/file1\n");

                FlagUtils.Set(flagFile, Path.Combine("dir2", "file2"));
                File.ReadAllText(flagFile).Should().Be("/dir1/file1\n/dir2/file2\n");
            }
        }
 protected override void CreateSymlink(string linkPath, string linkTarget)
 {
     if (_destinationIsUnixFS)
     {
         base.CreateSymlink(linkPath, linkTarget);
     }
     else
     {
         File.WriteAllText(linkPath, linkTarget, Encoding.UTF8);
         FlagUtils.Set(Path.Combine(DestinationPath, FlagUtils.SymlinkFile), new FileInfo(linkPath).RelativeTo(new DirectoryInfo(DestinationPath)));
     }
 }
Esempio n. 3
0
        protected void WriteFile(string name, bool executable = false)
        {
            string path = Path.Combine(_sourceDirectory, name);

            File.WriteAllText(path, Contents);
            File.SetLastWriteTimeUtc(path, Timestamp);

            if (executable)
            {
                if (UnixUtils.IsUnix)
                {
                    FileUtils.SetExecutable(path, true);
                }
                else
                {
                    FlagUtils.Set(Path.Combine(_sourceDirectory, FlagUtils.XbitFile), name);
                }
            }
        }
        protected override void CopyFile(FileInfo sourceFile, FileInfo destinationFile)
        {
            #region Sanity checks
            if (sourceFile == null)
            {
                throw new ArgumentNullException("sourceFile");
            }
            if (destinationFile == null)
            {
                throw new ArgumentNullException("destinationFile");
            }
            #endregion

            base.CopyFile(sourceFile, destinationFile);

            if (_sourceIsUnixFS && !_destinationIsUnixFS && FileUtils.IsExecutable(sourceFile.FullName))
            {
                FlagUtils.Set(Path.Combine(DestinationPath, FlagUtils.XbitFile), destinationFile.RelativeTo(new DirectoryInfo(DestinationPath)));
            }
        }