我正在尝试编写一个递归函数,它将返回数组中的信息,但是当我将一个return语句放入函数时,它会错过某些条目.
我试图以递归方式查看指定深度的文件夹,以获取与文件夹关联的acl.我知道getChildItem有一个递归选项,但我只想逐步浏览3个级别的文件夹.
以下代码的摘录是我一直用于测试的.如果在没有return语句的情况下调用getACLS(在下面注释掉),结果是:
文件夹1
文件夹12
文件夹13
文件夹2
当使用return语句时,我得到以下输出:
文件夹1
文件夹12
所以看起来return语句是从递归循环中退出的?
我的想法是,我想返回一个多维数组,如[文件夹名称,[acls],[[子文件夹,[权限],[[...]]]]]等.
cls
function getACLS ([string]$path, [int]$max, [int]$current) {
$dirs = Get-ChildItem -Path $path | Where { $_.psIsContainer }
$acls = Get-Acl -Path $path
$security = @()
foreach ($acl in $acls.Access) {
$security += ($acl.IdentityReference, $acl.FileSystemRights)
}
if ($current -le $max) {
if ($dirs) {
foreach ($dir in $dirs) {
$newPath = $path + '\' + $dir.Name
Write-Host $dir.Name
# return ($newPath, $security, getACLS $newPath $max ($current+1))
# getACLS $newPath …Run Code Online (Sandbox Code Playgroud) 我尝试使用旧的嵌入代码将YouTube视频添加到TinyMCE中,它运行正常.一些用户可能没有意识到他们必须点击YouTube嵌入代码链接中的旧嵌入代码选项才能添加它.
我想让用户轻松一点,让他们直接复制新的嵌入代码并将其粘贴到TinyMCE上,然后就可以了.
新的嵌入代码类似于以下示例:
<iframe title="YouTube video player" width="640" height="390"
src="http://www.youtube.com/embed/VvJ037b_kLs"
frameborder="0" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)
如何让TinyMCE接受使用iframe的新版YouTube嵌入代码?
我正在开发CakePHP网站.
嘿,我对C++有点新意,正在编写一个简单的程序.我的程序将使用一些文件夹
Windows 7路径:C:\ Users \%username%\ Appdata\Local ...
Windows XP路径:C:\ Documents and Settings \%username%\ Local Settings\Application Data ...
Unix:/ home /%username%/ .hiddenfolder/...
现在问题是windows.在我的头文件中,我可以做得很好
#ifdef _WIN32
区分Windows和unix版本的程序,但在运行时我需要找到用户是否使用XP或Vista/7来设置正确的路径.有这样做的标准方法吗?
在安全框架的背景下,一些术语通常出现在主题,用户和主体上,但我无法找到明确的定义和它们之间的区别.
那么,这些术语究竟是什么意思,为什么需要这些主题和主体的区别呢?
我正在使用UIImagePickerController捕获图像然后存储它.但是,当我尝试重新缩放它时,我从该图像中获取的方向值不正确.当我拿着手机向上拍摄时,它会给我左手方向.有没有人遇到过这个问题?
UIImagePickerController字典显示以下信息:
{
UIImagePickerControllerMediaMetadata = {
DPIHeight = 72;
DPIWidth = 72;
Orientation = 3;
"{Exif}" = {
ApertureValue = "2.970853654340484";
ColorSpace = 1;
DateTimeDigitized = "2011:02:14 10:26:17";
DateTimeOriginal = "2011:02:14 10:26:17";
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666666666666667";
FNumber = "2.8";
Flash = 32;
FocalLength = "3.85";
ISOSpeedRatings = (
125
);
MeteringMode = 1;
PixelXDimension = 2048;
PixelYDimension = 1536;
SceneType = 1;
SensingMethod = 2;
Sharpness = 1;
ShutterSpeedValue = "3.910431673351467";
SubjectArea = (
1023, …Run Code Online (Sandbox Code Playgroud) 我试图迭代一个字符串,以删除重复字符.
例如,字符串aabbccdef应该成为abcdef
,字符串abcdabcd应该成为abcd
这是我到目前为止:
public class test {
public static void main(String[] args) {
String input = new String("abbc");
String output = new String();
for (int i = 0; i < input.length(); i++) {
for (int j = 0; j < output.length(); j++) {
if (input.charAt(i) != output.charAt(j)) {
output = output + input.charAt(i);
}
}
}
System.out.println(output);
}
}
Run Code Online (Sandbox Code Playgroud)
做这个的最好方式是什么?
我只是想在windows下安装rmagick.
所以我用C/C++标头安装了ImageMagick,但似乎没有必要了.
然后我安装了Ruby Build Tools
ruby dk.rb init
ruby dk.rb install
Run Code Online (Sandbox Code Playgroud)
然后我想安装rmagick gem gem install rmagick.
但我得到这个错误:
H:\Downloads\ruby build tools>gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用evernote gem访问Evernote API.在这些说明中,它说要创建包含API帐户详细信息的配置文件,然后按如下方式加载配置文件:
config = File.dirname(__FILE__) + "/config.yml"
user_store = Evernote::UserStore.new(user_store_url, config, "sandbox")
Run Code Online (Sandbox Code Playgroud)
我evernote.yml在config文件夹中创建了一个文件,并将以下代码放入home操作中pages_controller.rb
config = File.dirname(__FILE__) + "/evernote.yml"
user_store = Evernote::UserStore.new(user_store_url, config, "sandbox")
Run Code Online (Sandbox Code Playgroud)
代码运行时,我在第二行收到此错误
Errno::ENOENT in PagesController#home
No such file or directory - /Users/ben/rails_projects/evernote_app/app/controllers/evernote.yml
Run Code Online (Sandbox Code Playgroud)
如何在不收到此错误的情况下加载配置文件?
是否可以计算字符串中预期的args/params的数量String.Format()?
例如:"Hello {0}. Bye {1}"应该返回2的计数.
我需要在string.Format()抛出异常之前显示错误.
谢谢你的帮助.