试图访问“当前目录"在打包的鞋子应用程序中 [英] Trying to access the "current dir" in a packaged Shoes app

查看:70
本文介绍了试图访问“当前目录"在打包的鞋子应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个应用来读取我将在其中分发的 Shoes 包外部的文件.

I need to build an app which reads a file which is external to the Shoes package I'll be distributing it in.

在我的应用程序中,Dir.pwd 指向脚本被解压以运行的临时目录(至少在 Windows 中).我一直在尝试获取运行 exe 的目录,即我正在分发的包.

In my app, Dir.pwd points to the temp dir (at least in Windows) where the script is unpacked to be ran. I've been trying to get the directory where the exe is running from, that is, the package I'm distributing.

应用程序需要读取除此包外分发的文件,然后在同一目录中写入另一个文件.

The app needs to read a file which is distributed besides this package and then write another one in the same directory.

Shoes 运行时似乎也没有为此目录设置任何环境变量.有什么指点吗?

It seems that the Shoes runtime does not set any env variable with this directory either. Any pointers?

纳乔克布

推荐答案

您是否尝试过类似以下的操作:

Have you tried something like the following:

DIR = File.expand_path __FILE__

__FILE__ 是对当前文件的引用,File.expand_path 为您提供完整的系统路径.适用于我的鞋子应用 :-)

__FILE__ is a reference to the current file and File.expand_path gives you the full system path. Works in my shoes apps :-)

穿上鞋子!

托比

这篇关于试图访问“当前目录"在打包的鞋子应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆