Exemple #1
0
        private bool OutputDirectoryNotValid(string outputdirPath)
        {
            if (!Directory.Exists(outputdirPath))
            {
                _log.Error("Output directory " + outputdirPath + " does not exist");
                return(true);
            }

            if (Environment.OSVersion.Platform == PlatformID.MacOSX ||
                Environment.OSVersion.Platform == PlatformID.Unix)
            {
                var ufi = new UnixFileInfo(outputdirPath);
                // accessible for writing
                if (!ufi.CanAccess(AccessModes.W_OK))
                {
                    _log.Error("Can't access output directory " + outputdirPath);
                    return(true);
                }
            }
            else
            {
                try
                {
                    Directory.GetAccessControl(outputdirPath);
                }
                catch (UnauthorizedAccessException e)
                {
                    _log.Error(e.Message);
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Checks and fixes execute permissions on the embedded binary if necessary.
        /// </summary>
        private static void CheckAndFixPermissions()
        {
            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                return;
            }

            var fileInfo = new UnixFileInfo("lib/youtube-dl");

            if (!fileInfo.CanAccess(AccessModes.X_OK))
            {
                fileInfo.FileAccessPermissions = fileInfo.FileAccessPermissions | FileAccessPermissions.UserExecute | FileAccessPermissions.GroupExecute | FileAccessPermissions.OtherExecute;
            }
        }