标签: path

系统重启后环境路径设置为“ PATH”变量丢失吗?

我已经设定

export PATH=$PATH:/home/user/android-sdk-linux/platform-tools
Run Code Online (Sandbox Code Playgroud)

并在命令行中执行上面的行,然后如果我键入echo $ PATH,我可以看到添加的路径。但是重新启动系统后,我再也看不到它了。但是让系统进入睡眠状态,然后重新启动,我仍然可以看到它。该如何解决?

unix linux android path-variables path

-1
推荐指数
1
解决办法
1057
查看次数

File :: Spec-> catpath不适用于Windows

我使用的File::Spec模块,像这样

my $volume = 'C';

my $path = File::Spec->catpath(
    $volume,
    File::Spec->catdir('panel', 'texts'),
    'file'
);

print $path;
Run Code Online (Sandbox Code Playgroud)

产量

Cpanel\texts\file
Run Code Online (Sandbox Code Playgroud)

如何在Perl中构建与OS无关的文件路径中File::Spec讨论的可移植模块如何?如果我必须写音量C:\而不只是C为了正确吗?

windows perl path

-1
推荐指数
1
解决办法
242
查看次数

斜线前的两个点是什么意思?(../)

../在Linux/Unix路径中意味着什么?我已经看到它意味着'上一个目录',但我无法完全理解它.

unix linux path

-1
推荐指数
1
解决办法
4000
查看次数

查找不带文件名的路径

我正在尝试创建一个程序来提供文件的完整路径。这可以使用 来完成File.absolute_path,但它还会将文件名添加到路径中。例如,

def test
  path = File.absolute_path("test.rb")
  puts path
end
#=> C:/users/james/myscripts/test/test.rb
Run Code Online (Sandbox Code Playgroud)

我需要排除最后一部分/test.rb,以便路径仅包含:C:/users/james/myscripts/test。有没有办法做到这一点?

ruby path

-1
推荐指数
1
解决办法
1591
查看次数

用单反斜杠替换双反斜杠

我有一个路径(例如C:\ Users \ chloe \ Documents),但是当我要将其保存在属性文件中时,由于字符串“ C:\ Users \ chloe \ Documents”,它会以双斜杠保存它由于某些原因,它没有放在\\C:之后。我在互联网上搜索,他们正在谈论replaceAll:

path.replaceAll("/+", "/");
Run Code Online (Sandbox Code Playgroud)

但这代替了常规的斜杠,我想知道如何用反斜杠...(在java中)

这是我写入属性文件的方式(仅需要的内容):

Properties prop = new Properties();
OutputStream output = null;


try {
                output = new FileOutputStream("config.properties");
                prop.setProperty("dir", path);
                prop.store(output, null);
            }catch(IOException e1){
                e1.printStackTrace();
            } finally {
                if (output != null) {
                    try {
                        output.close();
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }

            }

 path = System.getProperty("user.home") + File.separator + "AppData" + File.separator + "Roaming";
Run Code Online (Sandbox Code Playgroud)

java file path

-1
推荐指数
1
解决办法
1631
查看次数

_data列在FileProvider uri上不可用

我正在使用FileProvider模式来为文件创建content:// uri,

FileProvider.getUriForFile(this, "com.myapp.provider", file) 
Run Code Online (Sandbox Code Playgroud)

功能。我有清单,provider_paths和所有设置的标准方式,它创建了一个uri content://com.myapp.provider/external_files/music/mysong.mp3

我的问题是,如果我尝试在另一个应用程序中获取真实文件路径,则由于该_data列不存在而无法正常工作(具体来说,日志中的错误是E/CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 0 columns.)。为了获取真实路径,我使用了非常标准的功能

final String column = MediaStore.Files.FileColumns.DATA;
final String[] projection = { column  };
try {
    cursor = context.getContentResolver().query(uri, projection, null, null, null);
    if (cursor != null && cursor.moveToFirst()) {
        final int column_index = cursor.getColumnIndexOrThrow(column);
        return cursor.getString(column_index);
    }
} finally {
    if (cursor != null)
        cursor.close();
}
Run Code Online (Sandbox Code Playgroud)

如果我使用其他应用程序共享同一文件,则会生成一个类似uri的uri content://com.otherapp.provider/external_files/music/mysong.mp3,我已经可以从中检索真实的文件路径。有什么想法可以做,以确保我的应用正确地将给定的uri插入到ContentResolver中?contentResolver.insert(...)不允许使用手动功能。我尝试了不同版本的provider_paths.xml,并为给定的uri授予了所有可能的读/写权限,但是我永远无法检索真实路径。

由我生成的uri本身可以正常工作,因为我可以读取文件或播放歌曲,我的问题是我无法检索所需的真实文件路径。 …

android uri file path android-contentresolver

-1
推荐指数
1
解决办法
1805
查看次数

在路径前面加上“ -I”和“ -L”是什么意思?

使用brew安装opensl时,输出部分响应:

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"
Run Code Online (Sandbox Code Playgroud)

并且以下代码可用于编译C ++文件。

g ++ file.cpp -I / usr / local / opt / openssl / include

-I和-L分别代表什么?

c++ macos openssl path

-1
推荐指数
1
解决办法
40
查看次数

path.IsAbs 为 Windows 路径返回错误的结果

path.IsAbs 的文档说IsAbs报告路径是否是绝对的。我的代码中有一个函数来检查第一个参数是否是绝对的,如果不是,它会创建一个绝对路径。

func getPath() string {
    var dir string
    fmt.Printf("first arg -> %s and is it abs? %t\n", os.Args[1], path.IsAbs(os.Args[1]))
    if path.IsAbs(os.Args[1]) {
        dir = os.Args[1]
    } else {
        var currentDir string
        currentDir = filepath.Dir(os.Args[0])
        dir, _ = filepath.Abs(path.Join(currentDir, os.Args[1]))
    }
    return dir
}
Run Code Online (Sandbox Code Playgroud)

输出是 first arg -> C:\Users\Mohammad\Music\Uncategorized\Telegram and is it abs? false

但第一个论点是绝对的,所以我错过了什么?

path absolute-path go

-1
推荐指数
1
解决办法
101
查看次数

Delphi读取Windows 11系统路径

我正在开发在 64 位 Windows 11 上运行的 Delphi 12 应用程序。我的应用程序需要从注册表中读取路径(用户路径和系统路径),并且我的应用程序可以读取用户路径,但不能读取系统路径。

我使用“工具”->“选项”->“清单”要求管理员权限才能执行该程序,当我运行该应用程序时,它会提示我授权管理员模式,所以我知道它的一部分正在工作。

我已经在互联网上搜索了好几天寻找解决方案,并且尝试了我能找到的所有选项(Embarcadero 的网站本周关闭,这使得所有这一切变得更加困难,因为我在那里找到了许多文章参考文档)并且每次,代码成功打开指定的键 ( SYSTEM\CurrentControlSet\Control\Session Manager\Environment),但无法读取其中的任何属性(如path属性)。

我什至尝试TStringList使用该键下的所有属性填充 a

我创建了一个示例应用程序来演示这一点,您可以在https://github.com/johnwargo/Path-Test-2024找到它。

procedure PopulateList(pathList: TListBox; source: String; rootKey: HKEY;
  regKey, regProperty: String);
var
  Reg: TRegistry;
  pathArray: Tarray<String>;
  msg, pathStr: String;

begin
  LogMessage(Format('Reading "%s" Path from "%s"', [source, regKey]));
  // Reg := TRegistry.Create(KEY_ALL_ACCESS);
  // Reg := TRegistry.Create(KEY_ALL_ACCESS OR KEY_WOW64_64KEY);
  // Reg := TRegistry.Create(KEY_EXECUTE);
  // Reg := TRegistry.Create(KEY_EXECUTE OR KEY_WOW64_64KEY);
  // Reg := TRegistry.Create(KEY_READ OR KEY_WOW64_32KEY);
  Reg := TRegistry.Create(KEY_READ …
Run Code Online (Sandbox Code Playgroud)

windows delphi registry path

-1
推荐指数
1
解决办法
191
查看次数

Perl修剪路径正则表达式

所以我正在修剪一条看起来像这样的路径:

E:\folder\00000000\file.txt
Run Code Online (Sandbox Code Playgroud)

我想替换这个:

E:\folder\
Run Code Online (Sandbox Code Playgroud)

我无法想出正则表达式.

之前我确实问过这个问题但得到了混合的订单.

regex perl path

-3
推荐指数
1
解决办法
534
查看次数